home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / COM / ProTERM Mac1.2a.sit / ProTERM Mac1.2a / Help / DIRC Reference < prev    next >
Text File  |  1996-08-05  |  104KB  |  2,054 lines

  1. *** DIRC Programmer Reference ***
  2.  
  3. This document provides information about built-in library functions available in DIRC. It is provided in electronic form due to the dynamic and changing nature of the library functions. The newest version of this document is available via the internet:
  4.  
  5.     FTP://ftp.intrec.com/pub/intrec/mac_files/
  6.     HTTP://www.intrec.com
  7.  
  8. □*** Predefined Constants ***
  9.  
  10. Some special values have been predefined and given symbolic names to make them easier to use. For example, if you are writing an expression that requires a boolean TRUE value, you could enter the literal number メ1モ (since TRUE is an integer value of 1). As an alternative, you could enter メ#TRUEモ. The メ#TRUEモ is called a メsymbolic constantモ because it is a symbol that represents a constant value. The following predefined constants are available for use within your macro programs:
  11.  
  12.  #TRUE        Same as an integer value of 1.
  13.  #FALSE        Same as an integer value of 0.
  14.  #DefnAccess    Used by RESIDENT() to control access to resident macros.
  15.  #KeyAccess    Used by RESIDENT() to control access to resident macros.
  16.  #LibAccess    Used by RESIDENT() to control access to resident macros.
  17.  #EventAccess    Used by RESIDENT() to control access to resident macros.
  18.  
  19. □*** Predefined Functions ***
  20.  
  21. Most macro programs are actually references to one or more メpredefined functionsモ that are included to speed development of macro programs. These functions allow interacting with services, numeric computation and string manipulation, creation and changes to windows and access to the user interface. The functions are listed according to category. A complete alphabetical list and short summary of the functions can be found at the end of the chapter. Throughout this section, the following abbreviations and formatting notations are used:
  22.  
  23. FUNCTION
  24.         The name of the function is displayed in a bold typeface.
  25.  
  26. INT xxx
  27.         An expression that evaluates to an integer must be used in place of this text. The xxx is used within the description of the function to explain the relation of this expression to the operation of the function.
  28.  
  29. STR xxx
  30.         An expression that evaluates to a string must be used in place of this text. The xxx is used within the description of the function to explain the relation of this expression to the operation of the function.
  31.  
  32. EXPR xxx
  33.         Any valid expression (that returns either integer, boolean or string) must be used in place of this text. The xxx is used within the description of the function to explain the relation of this expression to the operation of the function.
  34.  
  35. [ text ]
  36.         Text within brackets represents optional function arguments, not required by the function. The text in brackets will be in one of the preceding formats.
  37.  
  38. [ ... ]
  39.         Three periods within brackets indicates that there can be additional expressions of the preceding type.
  40.  
  41. □*** Service Interaction Functions ***
  42.  
  43. The following group of functions are used to interact with a service. The WT()/PR()/SY() functions are the basis for most logon macros. The AutoLearn generator uses these functions when it create logon macros. For those developing complex service interaction macros, it is benefitial to understand the difference between synchronous and asynchronous terminal window operation. For those just getting started with DIRC, skip down to the function descriptions.
  44.  
  45. ** Synchronous & Asynchronous Mode **
  46.  
  47. By default, the terminal window operates in asyncronous mode. This means that incoming text from the service is displayed as soon as it received. However, when a macro is waiting for some particular text from a service, the terminal window needs to operate in synchronous mode. This means that incoming data is only processed when the macro is ready for it. In most cases, the switch between these modes is made automatically, and the DIRC programmer need not worry about it.
  48.  
  49. The most common situation which causes confusion is when developing a macro which initially performs some service interaction, and then continues running, but no longer interacts with the service. In this case, the terminal window appears to get メstuckモ after the interaction is complete. In fact, the terminal window is actually in synchronous mode and is saving the incoming data waiting for the next WT() function in the macro (which never comes). The terminal window can be forced into asynchronous mode by using the WT(0) function. Likewise, it can be forced into synchronous by using PR("").
  50.  
  51. ** PR() **
  52.  
  53. PR([INT pace,] STR text);
  54.  
  55. The PR() function sends the expression text to a service. An optional pace expressions controls the rate at which text is sent in 1/100th of a second (this is the time interval between sending individual characters).
  56.  
  57. Examples:
  58. PR(メhelloモ);    // send メhelloモ to the service
  59. PR(10,メ@D^mモ);    // pace=10/100 sec
  60. PR(メモ);        // force synchronous mode
  61.  
  62. ** PF() **
  63.  
  64. PF([INT pace,] STR text);
  65.  
  66. The PF() function is identical to the PR() function except that the PF() function does not display text in the terminal window even if the connect options are set for half duplex. The PF() function is used to conceal passwords and account numbers being sent to half duplex services.
  67.  
  68. Examples:
  69. PF(メaccountモ);    // send account information
  70. PF(メpasswordモ);    // send password information
  71.  
  72. ** SY() **
  73.  
  74. SY([INT delay,] STR text);
  75.  
  76. The SY() function attempts to synchronize to a service which requires some character sequence to be sent at intervals. The text (character sequence) is sent at a specified interval expressed in 1/100th of a second (the default is two seconds). If no response is received from the service within the delay period, the process is repeated. This is commonly used at the beginning of logon macros.
  77.  
  78. Examples:
  79. SY("^m");    // send ^M every 2 secs until response
  80. SY(100,"@D^m");    // send @D^m every 1 sec until response
  81.  
  82. ** WT() **
  83.  
  84. INT match = WT([INT timeout] [STR text] [ ... ]);
  85.  
  86. The WT() function waits for a period of time, or until a particular string is received from a service, or for both. The syntax of the WT() function is unusual because all the arguments are optional (though at least one argument is always required). The WT() function is normally used in one of the following forms:
  87.  
  88. WT(INT timeout);
  89. INT match = WT(STR text, [ ... ]);
  90. INT match = WT(INT timeout, STR text, [ ... ]);
  91.  
  92. In the first form, WT() waits for a specified period of time (in 1/100ths of a second). In the second form, WT() waits for a string from a service (from a list of one or more strings). In the third form, WT() waits for a string from a service or a period of time, whichever comes first. The result of the WT() function is always 0 for a timeout (the period of time expired) or a number corresponding to the string that was received. If you use WT(メaモ,メbモ,メcモ), then the result is 1 for メaモ, 2 for メbモ and 3 for メcモ. If an empty (null) string is included, any incoming data matches the string. The empty string is normally used with a timeout to detect the absence of incoming data.
  93.  
  94. Examples:
  95. WT(500);        // wait for 5 seconds
  96. WT(メaccount:モ);        // wait for the string メaccount:モ
  97. WT(200,メpassword:モ);    // wait for 2 secs or メpassword:モ
  98. WT(100,メモ);        // wait for 1 sec or incoming data
  99. x = WT(100,メmailモ);    // timeout: x=0; receive メmailモ: x=1
  100. DO { WT(メprompt:モ) } WHILE(WT(100,モモ));    // wait for prompt or 1 sec inactivity
  101. WT(0);            // force asynchronous mode
  102.  
  103. ** IN() **
  104.  
  105. STR data = IN([INT timeout,]STR terminator[,INT limit][,STR options]);
  106.  
  107. The IN() function waits for input from a service. The input can be terminated by either a specific termination character (such as RETURN), or a timeout, or an input length limit. The terminator argument is always required, but can be passed as a null string to indicate no terminator should be used. In such a case, the timeout or limit should be used. The timeout is specified in 1/100ths of a second. The limit can range from 1 to 1000 characters. Input is not processed in any way before it is returned (i.e., high-bits are NOT stripped, control characters are NOT removed). If a terminator character is specified and received, it is included as the last character of the input.
  108.  
  109. Examples:
  110. xyz = IN("^m");        // wait a input terminated by RETURN
  111. ch = IN("",1);        // wait for a single character
  112. inp = IN(500,"^m",80);    // wait for 5 seconds, a RETURN or 80 characters
  113.  
  114. ** SES_GET() **
  115.  
  116. STR value = SES_GET([INT session,] STR option);
  117.  
  118. The SES_GET() function returns the value of a session option. The session indicates which online session the option refers to (when zero or omitted, the current session is used). The option is a string which corresponds to one of the items in a connect file. The following options are supported:
  119.  
  120. NAME, FILE, PHONE NUMBER, METHOD, SPEED, FORMAT, TIMEOUT, DUPLEX, ECHO, CLOSE WINDOW AFTER CONNECT, SHOW DISCONNECT WINDOW, SHOW ONLINE STATUS WINDOW, IGNORE DUPLEX IN CHAT MODE, RECORD CONNECT IN LOG, LAST CONNECT, DISPLAY, FOREGROUND, BACKGROUND, USE COLOR, CUSTOMIZE, KEYBOARD, DELETE KEY, BACKSPACE, REMOTE PRINT, ANSWERBACK, TERM WINDOW NAME, LINE LIMIT, DELETE COUNT, FONT SIZE, USE EXISTING TERMINAL WINDOW, WARN WHEN TERMINAL WINDOW FULL, SEND MODE, RECEIVE MODE, PROTOCOL SPEED, EXISTING FILES, ALLOW RESUME, AUTO-RECEIVE, PROMPT, CHAR PACE, LINE PACE, TEXT WIDTH, BLANK LINES, PASTE CHAR PACE, PASTE LINE PACE, LOGON MACRO, MACRO, MAC1, MAC2, MAC3, MAC4, MAC5, MAC6, MAC7, MAC8, MAC9
  121.  
  122. Examples:
  123. PRINT(SES_GET(メSPEEDモ));
  124. PRINT(SES_GET(メNAMEモ));
  125.  
  126. ** SES_SET() **
  127.  
  128. SES_SET([INT session,] STR option, STR value);
  129.  
  130. The SES_SET() function sets the value of a session option. The session indicates which online session the option refers to (when zero or omitted, the current session is used). The option is a string which corresponds to one of the items in a connect file. The value is a string containing the appropriate value for that option. In the case of checkbox options (items that are enabled or disabled), the value is the literal string メ0モ (disabled) or メ1モ (enabled). The following options are supported:
  131.  
  132. PHONE NUMBER, METHOD, SPEED, FORMAT, TIMEOUT, DUPLEX, ECHO, CLOSE WINDOW AFTER CONNECT, SHOW DISCONNECT WINDOW, SHOW ONLINE STATUS WINDOW, IGNORE DUPLEX IN CHAT MODE, RECORD CONNECT IN LOG, LAST CONNECT, DISPLAY, FOREGROUND, BACKGROUND, USE COLOR, CUSTOMIZE, KEYBOARD, DELETE KEY, BACKSPACE, REMOTE PRINT, ANSWERBACK, TERM WINDOW NAME, LINE LIMIT, DELETE COUNT, FONT SIZE, USE EXISTING TERMINAL WINDOW, WARN WHEN TERMINAL WINDOW FULL, SEND MODE, RECEIVE MODE, PROTOCOL SPEED, EXISTING FILES, ALLOW RESUME, AUTO-RECEIVE, PROMPT, CHAR PACE, LINE PACE, TEXT WIDTH, BLANK LINES, PASTE CHAR PACE, PASTE LINE PACE, LOGON MACRO, MACRO, MAC1, MAC2, MAC3, MAC4, MAC5, MAC6, MAC7, MAC8, MAC9
  133.  
  134. Examples:
  135. SES_SET(メSPEEDモ, メ9600 BPSモ);
  136. SES_SET(メDUPLEXモ, メFULLモ);
  137.  
  138. □*** Boolean Functions ***
  139.  
  140. The boolean functions return information about variables and expressions. The results of the boolean functions are always 0 for FALSE and 1 for TRUE. To negate the result of a boolean function, use the ! (exclamation point) operator.
  141.  
  142. ** IS_VAR() **
  143.  
  144. INT flag = IS_VAR(identifier)
  145.  
  146. The IS_VAR() function returns the value 0 if identifier is not declared as a variable. It returns the value 1 if identifier is declared as a variable.
  147.  
  148. Examples:
  149. IF (IS_VAR(init)) { PRINT(メinit is a variableモ); };
  150. x = IS_VAR(xyzzy);    // x=1 if xyzzy declared as a variable
  151.  
  152. ** IS_NUM() **
  153.  
  154. INT flag = IS_NUM(EXPR expression)
  155.  
  156. The IS_NUM() function returns the value 1 if expression is numeric or 0 otherwise. This function is useful for creating functions that can accept either numeric or string arguments.
  157.  
  158. Examples:
  159. IF IS_NUM(ARGV(1)) {    // see if numeric or string
  160.  x = ARGV(1);        // if numeric, assign immediately
  161. } ELSE {        // otherwise
  162.  x = NUM_STR(ARGV(1))    // assign convert string to number
  163. }
  164.  
  165. ** IS_STR() **
  166.  
  167. INT flag = IS_STR(EXPR expression)
  168.  
  169. The IS_STR() function returns the value 1 if expression is a string or 0 otherwise. This function is useful for creating functions that can accept either numeric or string arguments.
  170.  
  171. Examples:
  172. IF IS_STR(ARGV(1)) {    // see if numeric or string
  173.  x = ARGV(1);        // if string, assign immediately
  174. } ELSE {        // otherwise
  175.  x = STR_NUM(ARGV(1))    // convert to string and assign
  176. }
  177.  
  178. ** IS_FILE() **
  179.  
  180. INT flag = IS_FILE(EXPR expression)
  181.  
  182. The IS_FILE() function returns the value 1 if expression is the name of a file or 0 otherwise. This function does not check the type of the file or any other attributes. It simply checks to see if a file of the specified name exists.
  183.  
  184. Examples:
  185. IF IS_FILE(メHD:ProTERM:my-fileモ) {    // see if the file exists
  186.  UI_OPEN(メHD:ProTERM:my-fileモ);        // if so, open it
  187. }
  188.  
  189. ** IS_class() **
  190.  
  191. INT flag = IS_class(EXPR expression)
  192. INT flag = IS_ALNUM(EXPR expression)
  193. INT flag = IS_ALPHA(EXPR expression)
  194. INT flag = IS_CNTRL(EXPR expression)
  195. INT flag = IS_DIGIT(EXPR expression)
  196. INT flag = IS_GRAPH(EXPR expression)
  197. INT flag = IS_LOWER(EXPR expression)
  198. INT flag = IS_PRINT(EXPR expression)
  199. INT flag = IS_PUNCT(EXPR expression)
  200. INT flag = IS_SPACE(EXPR expression)
  201. INT flag = IS_UPPER(EXPR expression)
  202. INT flag = IS_HEXID(EXPR expression)
  203.  
  204. The IS_class() functions returns the value 1 if expression is the particular type of character or 0 otherwise. If expression is an integer, the integer is converted to its ASCII character equivalent for comparison. If expression is a string, only the first character is compared. These functions return the value 1 in the following cases:
  205.  
  206.     IS_ALNUM()    If IS_ALPHA() or IS_DIGIT() is TRUE.
  207.     IS_ALPHA()    If IS_UPPER() or IS_LOWER() is TRUE.
  208.     IS_CNTRL()    If char is an ASCII control character.
  209.     IS_DIGIT()    If char is a digit (0-9).
  210.     IS_GRAPH()    If char is printable character except SPACE.
  211.     IS_LOWER()    If char is a lowercase letter (a-z).
  212.     IS_PRINT()    If char is any printable character.
  213.     IS_PUNCT()    If char is printable except SPACE, a-z, A-Z or 0-9.
  214.     IS_SPACE()    If char is SPACE, FF, NL, CR, TAB or VT.
  215.     IS_UPPER()    If char is an uppercase letter (A-Z).
  216.     IS_HEXID()    If char is a hexidecimal digit (0-9, A-F, a-f).
  217.  
  218. Examples:
  219. IF IS_LOWER(メaモ) { PRINT(メis lowercaseモ); }
  220. IF IS_DIGIT(メ5モ) { PRINT(メis digitモ); }
  221. IF IS_PRINT(34) { PRINT(メis printableモ); }
  222.  
  223. □*** Numeric Functions ***
  224.  
  225. The numeric functions perform calculations on expressions resulting in numeric values. In addition to these functions, keep in mind that numeric values can be directly manipulated with the + (addition), - (subtraction/negation), / (division), * (multiplication) and % (remainder/modulus) operators.
  226.  
  227. ** NUM_STR() **
  228.  
  229. INT value = NUM_STR(STR text);
  230. The NUM_STR() function converts a number in text form to an integer value. The resulting value is a positive or negative integer depending on the format of the number in text form.
  231.  
  232. Examples:
  233. PRINT(NUM_STR(メ27モ));    // displays 27
  234. xx = NUM_STR(メhelloモ);    // xx is set to 0
  235. i = NUM_STR(メ-33モ);    // i is set to -33
  236.  
  237. ** NUM_CHAR() **
  238.  
  239. INT value = NUM_CHAR(STR char);
  240.  
  241. The NUM_CHAR() function returns the character code of the first character of a string. The resulting character code value is in the range 0 to 255. An empty-string returns a value of -1.
  242.  
  243. Examples:
  244. PRINT(NUM_CHAR(メAモ));    // displays 65
  245. xx = NUM_CHAR(メモ);    // xx is set to -1
  246.  
  247. ** NUM_BYTE() **
  248.  
  249. INT value = NUM_BYTE(STR data);
  250.  
  251. The NUM_BYTE() function returns the byte value of the first character of a string. The resulting character code value is in the range 0 to 255. An empty-string returns a value of 0. The NUM_BYTE() function is very similar to the NUM_CHAR() function, and is provided as a counterpart for NUM_WORD() and NUM_LONG().
  252.  
  253. Examples:
  254. PRINT(NUM_BYTE(メAモ));    // displays 65
  255. xx = NUM_BYTE(メモ);    // xx is set to 0
  256.  
  257. ** NUM_WORD() **
  258.  
  259. INT value = NUM_WORD(STR data);
  260.  
  261. The NUM_WORD() function returns the word value of the first two characters of a string. The resulting character code value is in the range 0 to 65535. An empty-string returns a value of 0.
  262.  
  263. Examples:
  264. PRINT(NUM_WORD(メ@Aモ));    // displays 16449
  265. xx = NUM_WORD(メモ);    // xx is set to 0
  266.  
  267. ** NUM_LONG() **
  268.  
  269. INT value = NUM_LONG(STR data);
  270. The NUM_LONG() function returns the long word value of the first four characters of a string. The resulting character code value is in the range -2,147,483,684 to 2,147,483,683. An empty-string returns a value of 0. 
  271.  
  272. Examples:
  273. PRINT(NUM_LONG(メABCDモ));    // displays 1094861636
  274. xx = NUM_LONG(メxxモ);        // xx is set to 0 (too short)
  275.  
  276. ** NUM_MIN() **
  277.  
  278. INT min_value = NUM_MIN(INT val1 [,INT var2] [ ... ]);
  279.  
  280. The NUM_MIN() function returns the minimum value of all the arguments.
  281.  
  282. Examples:
  283. PRINT(NUM_MIN(3,2,9));    // display 2
  284. PRINT(NUM_MIN(7,-5));    // display -5
  285.  
  286. ** NUM_MAX() **
  287.  
  288. INT max_value = NUM_MAX(INT val1 [,INT var2] [ ... ]);
  289.  
  290. The NUM_MAX() function returns the maximum value of all the arguments.
  291.  
  292. Examples:
  293. PRINT(NUM_MAX(3,2,9));    // display 9
  294. PRINT(NUM_MAX(7,-5));    // display 7
  295.  
  296. ** NUM_ABS() **
  297.  
  298. INT pos_value = NUM_ABS(INT pos_neg_value);
  299.  
  300. The NUM_ABS() function returns the absolute value of pos_neg_value.
  301.  
  302. Examples:
  303. PRINT(NUM_ABS(-1));    // display 1
  304. PRINT(NUM_ABS(0));    // display 0
  305. PRINT(NUM_ABS(1));    // display 1
  306.  
  307. ** NUM_LO16() **
  308.  
  309. INT value16 = NUM_LO16(INT value32);
  310.  
  311. Some functions return values in a メpacked 32-bit formatモ. The NUM_LO16() function converts the results of these functions into normal integer values. The packed number is passed as value32 and returned as value16. The conversion performed is to return the lower 16-bits of value32.
  312.  
  313. Examples:
  314. size = WIN_SIZE(WIN_ACTIVE(0));    // get window size in packed format
  315. PRINT(NUM_LO16(size));        / display horizontal width of window
  316. PRINT(NUM_HI16(size));        // display vertical length of window
  317.  
  318. ** NUM_HI16() **
  319.  
  320. INT value16 = NUM_HI16(INT value32);
  321.  
  322. Some functions return values in a メpacked 32-bit formatモ. The NUM_HI16() function converts the results of these functions into normal integer values. The packed number is passed as value32 and returned as value16. The conversion performed is to return the upper 16-bits of value32.
  323.  
  324. Examples:
  325. size = WIN_SIZE(WIN_ACTIVE(0));    // get window size in packed format
  326. PRINT(NUM_LO16(size));        // display horizontal width of window
  327. PRINT(NUM_HI16(size));        / display vertical length of window
  328.  
  329. ** NUM_RND16() **
  330.  
  331. INT random = NUM_RND16(INT seed);
  332.  
  333. The NUM_RND16() function returns a random number in the range 0 to 65535. To reduce the range, use the modulus (%) operator. The メrandomモ numbers are returned in a periodic sequence that repeats every 65536 times the NUM_RND16() function is used. The seed controls what the next random value will be. If set to -1, then the NUM_RND16() function keeps track of the メseedモ value. To generate a repeatable random sequence (one you can start over), use the previous random value as the seed for the next value.
  334.  
  335. Examples:
  336. x = NUM_RND16(-1) % 1000;    // assign メrandomモ number between 0ノ999
  337. x = 10;                // display 10 numbers
  338. rnd = 756;            // set the inital random メseedモ
  339. WHILE (x=x-1) {            // loop 10 times
  340.  rnd = NUM_RND16(rnd);        // generate random number from previous
  341.  PRINT(rnd % 1000,メ^mモ);    // display random number
  342. }                // displays same 10 メrandomモ numbers
  343.  
  344. □*** String Functions ***
  345.  
  346. The string functions perform calculations on expressions resulting in string values. In addition to these values, keep in mind that strings can also be directly manipulated through the use of the + (concatenation) operator.
  347.  
  348. ** STR_NUM() **
  349.  
  350. STR text = STR_NUM(INT value);
  351.  
  352. The STR_NUM() function returns the string equivilent of an integer expression. If value is negative, then the resulting text includes a minus sign.
  353.  
  354. Examples:
  355. PRINT(STR_NUM(27));    // display the string 27
  356. x = STR_NUM(y)+メ^mモ;    // create string from var メyモ
  357.  
  358. ** STR_CHAR() **
  359.  
  360. STR text = STR_CHAR(INT char_code);
  361.  
  362. The STR_CHAR() function returns a text string composed of a single character with the value char_code. If the char_code is greater than 256, then the value modulus 256 is used.
  363.  
  364. Examples:
  365. PRINT(STR_CHAR(64));    // display メ@モ (ASCII code 64)
  366. PRINT(STR_CHAR(321));    // display メAモ (ASCII code 65)
  367.  
  368. ** STR_BYTE() **
  369.  
  370. STR text = STR_BYTE(INT char_code);
  371.  
  372. The STR_BYTE() function returns a text string composed of a single character with the value char_code. If the char_code is greater than 256, then the value modulus 256 is used. STR_BYTE() is usually used with NUM_BYTE() to convert values between integers and strings. The STR_BYTE() function is very similar to the STR_CHAR() function, and is provided as a counterpart for STR_WORD() and STR_LONG().
  373.  
  374. Examples:
  375. PRINT(STR_BYTE(64));    // display メ@モ (ASCII code 64)
  376. PRINT(STR_BYTE(321));    // display メAモ (ASCII code 65)
  377.  
  378. ** STR_WORD() **
  379.  
  380. STR text = STR_WORD(INT char_code);
  381.  
  382. The STR_WORD() function returns a text string composed of two characters which represent the value char_code. If the char_code is greater than 65535, then the value modulus 65536 is used. STR_WORD() is usually used with NUM_WORD() to convert values between integers and strings. 
  383.  
  384. Examples:
  385. PRINT(STR_WORD(16449));            // display メ@Aモ
  386. PRINT(NUM_WORD(STR_WORD(12345)));    // display 12345
  387.  
  388. ** STR_LONG() **
  389.  
  390. STR text = STR_LONG(INT char_code);
  391.  
  392. The STR_LONG() function returns a text string composed of four characters which represent the value char_code. STR_LONG() is usually used with NUM_LONG() to convert values between integers and strings. 
  393.  
  394. Examples:
  395. PRINT(STR_LONG(1094861636));        // display メABCDモ
  396. PRINT(NUM_LONG(STR_LONG(12345)));    // display 12345
  397.  
  398. ** STR_TOHEX() **
  399.  
  400. STR text = STR_TOHEX(STR raw)
  401.  
  402. The STR_TOHEX() function takes a raw binary string (a string containing any character in the range 0-255) and converts it to a hexidecimal coded string (with characters in the range 0-9, A-F). This is a useful way to take binary string data and convert it to a visible format for storage or diagnostic display. The STR_FROMHEX() function (see below) will convert a hexidecimal string back into binary form.
  403.  
  404. Examples:
  405. PRINT(STR_TOHEX("abc"));        // display "616263"
  406.  
  407. ** STR_FROMHEX() **
  408.  
  409. STR raw = STR_FROMHEX(STR text)
  410.  
  411. The STR_FROMHEX() function takes a hexidecimal coded text string (a string containing characters in the range 0-9, A-F) and converts it to a binary string (with characters in the range 0-255). This function is used with the STR_TOHEX() function (see above) to convert binary data into and outof a visible string format.
  412.  
  413. Examples:
  414. PRINT(STR_FROMHEX("616263"));        // display "abc"
  415.  
  416. ** STR_LEN() **
  417.  
  418. INT length = STR_LEN(STR text)
  419.  
  420. The STR_LEN() function returns the length (in characters) of the text. The length can be in the range 0 and 32,000. The empty string has a length of 0.
  421.  
  422. Examples:
  423. len = STR_LEN(メhelloモ);    // assign 5 to the variable メlenモ
  424. PRINT(STR_LEN(メモ));    // display 0
  425.  
  426. ** STR_LEFT() **
  427.  
  428. STR left = STR_LEFT(STR text, INT length);
  429.  
  430. The STR_LEFT() function returns a left string composed of the left-most characters from the text. The length of the left string is equal to length (or less if text is shorter than length). If length is zero, then an empty string is returned.
  431.  
  432. Examples:
  433. PRINT(STR_LEFT(メabcdeモ,3));    // display メabcモ
  434. PRINT(STR_LEFT(メ123モ,15));    // display メ123モ
  435.  
  436. ** STR_RIGHT() **
  437.  
  438. STR right = STR_RIGHT(STR text, INT length);
  439.  
  440. The STR_RIGHT() function returns a right string composed of the right-most characters from the text. The length of the right string is equal to length (or less if text is shorter than length). If length is zero, then an empty string is returned.
  441.  
  442. Examples:
  443. PRINT(STR_RIGHT(メabcdeモ,3));    // display メcdeモ
  444. PRINT(STR_RIGHT(メ123モ,15));    // display メ123モ
  445.  
  446. ** STR_MID() **
  447.  
  448. STR mid = STR_MID(STR text, INT offset, INT length);
  449.  
  450. The STR_MID() function returns a mid string composed of characters from the middle of text. The start of the mid string is determined by the offset relative to the left side of text. An offset of zero returns a mid string starting at the left-most character (the same as using the STR_LEFT() function). The length of mid string is equal to length (or less if text is shorter than length). If length is zero, then an empty string is returned.
  451.  
  452. Examples:
  453. PRINT(STR_MID(メabcdeモ,2,2));    // display メcdモ
  454. PRINT(STR_MID(メ123モ,2,15));    // display メ3モ
  455. PRINT(STR_MID(メabcdeモ,0,3));    // display メabcモ
  456.  
  457. ** STR_UPPER() **
  458.  
  459. STR upper = STR_UPPER(STR text);
  460.  
  461. The STR_UPPER() function returns text converted to uppercase.
  462.  
  463. Examples:
  464. PRINT(STR_UPPER(メAbCdEfモ));    // display メABCDEFモ
  465.  
  466. ** STR_LOWER() **
  467.  
  468. STR lower = STR_LOWER(STR text);
  469.  
  470. The STR_LOWER() function returns text converted to lowercase.
  471.  
  472. Examples:
  473. PRINT(STR_LOWER(メAbCdEfモ));    // display メabcdefモ
  474.  
  475.  ** STR_REPEAT() **
  476.  
  477. STR pattern = STR_REPEAT(STR text, INT length);
  478.  
  479. The STR_REPEAT() function returns a pattern created by concatenating text together until the length is reached. The resulting pattern is always exactly length characters.
  480.  
  481. Examples:
  482. PRINT(STR_REPEAT(メ<>モ,78);    // display a line of <><><><>
  483. PRINT(STR_REPEAT(メ-モ,79);    // display a line of ------------
  484.  
  485. ** STR_INDEX() **
  486.  
  487. INT offset = STR_INDEX(STR match, STR target, [INT offset]);
  488.  
  489. The STR_INDEX() function searches for one string within another. It returns the offset at which the match string occurs within the target string or -1 if it does not occur. The matching portion of the target string must be identical to the match string (includes matching case). The optional offset argument allows the search to be started at a point beyond the first character. Omitting the offset argument is the same as specifying a value of 0 which starts searching from the first character.
  490.  
  491. Examples:
  492. PRINT(STR_INDEX("c","abcdef"));        // display 2
  493. PRINT(STR_INDEX("gs","hello"));        // display -1
  494. PRINT(STR_INDEX("c","abcdef",4));    // display -1
  495.  
  496. ** STR_RINDEX() **
  497.  
  498. INT offset = STR_RINDEX(STR match, STR target, [INT offset]);
  499.  
  500. The STR_RINDEX() function is very similar to the STR_INDEX() function except that it searches from right-to-left instead of left-to-right. Other than the seach order, the operation is the same. STR_RINDEX() returns the offset at which the match string occurs within the target string or -1 if it does not occur. The matching portion of the target string must be identical to the match string (includes matching case). The optional offset argument allows the search to be started at an arbitrary point.
  501.  
  502. ** STR_FORMAT() **
  503.  
  504. STR formatted = STR_FORMAT(STR control, [INT arg1] [...]);
  505.  
  506. The STR_FORMAT() function returns a formatted text string. The control string is used as a template for the final formatted text. In addition to normal text, the control string can contain special メformatting tokensモ which are replaced in the final text by additional arguments formatted according to the token. The following format tokens are supported:
  507.  
  508. * Format Tokens *
  509.  
  510. %%    Replace with a percent sign. No argument corresponds to this formatting code.
  511.  
  512. %c    Replace with a single character. The corresponding argument must be an INT containing the character code (0ノ255).
  513.  
  514. %d    Replace with a signed decimal value. The corresponding argument must be an INT containing the value.
  515.  
  516. %s    Replace with a string. The corresponding argument must be an STR containing the string.
  517.  
  518. %u    Replace with an unsigned decimal value. The corresponding argument must be an INT containing the value.
  519.  
  520. %x    Replace with the hexadecimal value. The corresponding argument must be an INT containing the value.
  521.  
  522. %D    Replace with a date. The corresponding argument must be an INT containing the date in elapsed seconds from Jan 1, 1904. A value of zero causes replacement with the current date.
  523.  
  524. %K    Replace with a value in メK-bytes.モ The corresponding argument must be an INT containing the number of bytes.
  525.  
  526. %M    Replace with the elapsed time in milliseconds. The corresponding argument must be an INT containing the number of elapsed ticks. To convert seconds to ticks, multiply by 60.
  527.  
  528. %P    Replace with a four-character メtypeモ string. The corresponding argument must be an INT containing a メtypeモ in メpacked format.モ
  529.  
  530. %S    Replace with the elapsed time in seconds. The corresponding argument must be an INT containing the number of elapsed ticks. To convert seconds to ticks, multiply by 60.
  531.  
  532. %T    Replace with a time. The corresponding argument must be an INT containing the time in elapsed seconds from midnight of any day (including Jan 1, 1904). A value of zero causes replacement with the current time.
  533.  
  534. %V    Replace with a version number. The corresponding argument must be an INT. The resulting value is displayed as the top 16-bits of the value followed by a period followed by the next 8-bit of the value. If the final 8-bit of the value is non-zero, then a period followed by that value is appended.
  535.  
  536. Examples:
  537. x = STR_FORMAT(メ%dモ,27);        // conv 27 to string
  538. y = STR_FORMAT(メ%s %sモ,a,b);        // concat a & b
  539. PRINT(STR_FORMAT(メtime: %D %T^mモ,0,0));    // display current date & time
  540. PRINT(STR_FORMAT(メ%s %s ^mモ,メhelloモ,メworldモ));    // display メhello worldモ
  541. PRINT(STR_FORMAT(メ%d%% doneモ,x));    // display a percent value
  542.  
  543. ** STR_PARSE() **
  544.  
  545. INT items = STR_PARSE(STR text, STR format, [VAR arg1] [...]);
  546.  
  547. The STR_PARSE() function parses data from text string, assigning it to variables according to a format string. This function operates similar to the C scanf function, except it includes additional control over what defines a string (i.e., it can be more than just a sequence of characters terminated by white-space ). The items value indicates the number of variables assigned by the function.
  548.  
  549. The actual parsing is controlled by the format string which contains tokens, similar to the STR_FORMAT() function (see above). The tokens are all prefixed by the % character and indicate the type of parsing to take place. The character following a token is used to deliniate the text for parsing purposes. If a space follows a token, than any white-space character (ASCII characters 9, 10, 11, 12, 13 and 32) deliniates the parsing. When a token appears at the end of the formatting string, it is the same as if a space followed the token. Non-token characters within the format string are used to メskipモ past text. The following tokens are supported:
  550.  
  551. * Scan Tokens *
  552.  
  553. %c    Take a single character and assign it to the corresponding string variable.
  554.  
  555. %d    Take a signed number and assign it to the corresponding string. The number with start with either a + or - to indicate its sign. A number is always deliniated by the first non-digit.
  556.  
  557. %s    Take a sequence of characters (a string) and assign itto the corresponding string variable. The character following this token is used to determine what marks the end of the string. Note that the RETURN character always deliniates a string even if another character is specified. To make RETURN the only deliniator character, follow the token with a ^M.
  558.  
  559. %u    Take an unsigned number and assign it to the corresponding string. The number must start with a digit and is deliniated by the first non-digit.
  560.  
  561. %*<token>    The %*c, %*d, %*s, %*u tokens work identical to those above with the *, except they do not assign their values to variables. Instead, they are used strictly as formatting operators to skip past unneeded data. 
  562.  
  563. %<width>s    This is a special version of %s which allows a maximum string width to be specified. The maximum width is specified as a decimal number (i.e., %10s).
  564.  
  565. Examples:
  566. text = メ27 4 23モ;
  567. STR_PARSE(text,"%d %d %d",a,b,c);    // a=27, b=4, c=23
  568. text = メhello world^mモ
  569. STR_PARSE(text,メ%s^mモ,x);        // x=hello world
  570. text = メ56,phoenixモ;
  571. STR_PARSE(text,メ%d,%s^mモ,a,b);        // a=56, b=phoenix
  572. text = メ352,5345,apple^mモ;
  573. STR_PARSE(text,メ%*d,%*d,%s^mモ,x);    // x=apple
  574. text = メabcdefghijklモ;
  575. STR_PARSE(text,メ%4s%4s%4sモ,a,b,c);    // a=abcd, b=efgh, c=ijkl
  576.  
  577. □*** Array Functions ***
  578.  
  579. DIRC does not currently support arrays as an actual data type. Therefore, the following library functions have been provided to allow manipulation of simple array-like data structures. These routines メpackageモ array data into a single large メarrayモ string which is passed to routines in the library. The routines are simple enough that they can actually be coded directly in DIRC (though the library versions are faster).
  580.  
  581. ** ARRAY_NUM() **
  582.  
  583. STR array = ARRAY_NUM(INT size);
  584.  
  585. The ARRAY_NUM() function creates a new array consisting of size numeric elements. The resulting array is a メpacked stringモ which must be passed to other array routines in order to get/set the elements.
  586.  
  587. Examples:
  588. ar = ARRAY_NUM(10);    // create a new array
  589. ar = ARRAY_SET(ar,2,x);    // set element 2 to x
  590.  
  591. ** ARRAY_STR() **
  592.  
  593. STR array = ARRAY_STR(INT size, INT width);
  594. The ARRAY_STR() function creates a new array consisting of size string elements of maximum width. The resulting array is a メpacked stringモ which must be passed to other array routines in order to get/set the elements.
  595.  
  596. Examples:
  597. ar = ARRAY_STR(10,20);        // create with elements=10, width=20
  598. ar = ARRAY_SET(ar,3,メhelloモ);    // set element 2 to メhelloモ
  599.  
  600. ** ARRAY_SIZE() **
  601.  
  602. INT size = ARRAY_SIZE(STR array, INT what);
  603.  
  604. The ARRAY_SIZE() function returns the number of elements in an array or the maximum width of the elements. If the maximum width of an array is 4, then the array is numeric. Otherwise, if the maximum width is greater than 4, then the array contains strings. To get the number of elements, pass 0 in the what argument. To get the maximum element width, pass 1 in the what argument.
  605.  
  606. Examples:
  607. ar = ARRAY_STR(10,20);        // create with elements=10, width=20
  608. PRINT(ARRAY_SIZE(ar,0));    // display number of elements (10)
  609. PRINT(ARRAY_SIZE(ar,1));    // display maximum element width (20)
  610.  
  611. ** ARRAY_GET() **
  612.  
  613. VAR element = ARRAY_GET(STR array, INT index);
  614.  
  615. The ARRAY_GET() function returns the contents of an element from an array. The index  argument must be within the valid range for the array (or else an error is generated). The returned element will be either a string or integer depending on the type of the array.
  616.  
  617. Examples:
  618. ar = ARRAY_STR(10,20);        // create with elements=10, width=20
  619. ar = ARRAY_SET(ar,5,メhelloモ);    // set element 5 to メhelloモ
  620. PRINT(ARRAY_GET(ar,5));        // display element 5 (hello)
  621.  
  622. ** ARRAY_SET() **
  623.  
  624. STR array = ARRAY_SET(STR array, VAR data, INT index);
  625.  
  626. The ARRAY_SET() function sets the contents of an array element and returns an updated array. The index argument must be within the valid range for the array (or else an error is generated). The type of data must agree with the type of the array (integer or string).
  627.  
  628. Examples:
  629. ar = ARRAY_STR(10,20);        // create with elements=10, width=20
  630. ar = ARRAY_SET(ar,5,メhelloモ);    // set element 5 to メhelloモ
  631. PRINT(ARRAY_GET(ar,5));        // display element 5 (hello)
  632.  
  633. □*** File Functions ***
  634.  
  635. The following functions are related to the selection and manipulation of files and filenames. To actually input/output information to/from a file, see Input/Output Functions below. Several of the filename function make use of メpathname indexesモ which are a simple way of specifying a preset pathname. The pathname indexes are explained below in advance of the functions which use them.
  636.  
  637.  
  638. ** Pathname Indexes **
  639.  
  640. There are sixteen pathname indexes available for use by macro programs. Within the application, these indexes are used primarily to keep track of the default pathname for file selector dialogs. For example, index 1 is used to maintain the default folder used for the Open command. The list below tells which indexes are used by the application. A macro can change a pathname index used by the application to make file selection default to a different folder. 
  641.  
  642.     0 =    Last used pathname
  643.     1 =    Open pathname
  644.     2 =    Exec pathname
  645.     3 =    Send pathname
  646.     4 =    Receive pathname
  647.     5 =    Connect folder pathname
  648.     6 =    Unused
  649.     7 =    Reserved for macro programs
  650.     8-15 =    Unused
  651.  
  652. Each pathname index has two attributes associated with it. The first is the pathname itself which determines the initial folder used during file selection.. The second is called the springback flag which flag determines whether changing the folder during file selection should update the pathname index. For example, when the standard file selector is used with a index value of 1, it starts out at the folder which index 1 represents. During file selection, the folder may get changed. When file selection is completed, the setting of the springback flag determines whether the new folder is saved as the default for subsequent file selection or not.
  653.  
  654. ** Folder Shortcuts **
  655.  
  656. ProTERM defines three special メshortcutsモ which can be used within pathnames to simplify macro development. When shortcuts are used in a pathname, they represent folders which ProTERM considers significant. The following shortcuts work under both System 7 and System 6. The shortcuts are:
  657.  
  658. .APPL:    The folder containing the ProTERM application program.
  659. .SYST:    The folder containing the active system software.
  660. .PREF:    The folder containing the ProTERM preference files.
  661.  
  662. Examples:
  663. IF (IS_FILE(".APPL:Test File")) { ... }
  664. EXTERN(".PREF:My-Macros", main());
  665.  
  666. ** FN_RESOLVE() **
  667.  
  668. STR name = FN_RESOLVE(STR basename, STR filename);
  669.  
  670. The FN_RESOLVE() function resolves a filename/pathname based on an existing pathname. The basename string is first completely resolved to a folder. The filename string is then resolved relative to the basename folder. If filename is a full pathname (includes a volume name), then the basename has no effect.
  671.  
  672. Examples:
  673. path = FN_RESOLVE(path,"::");    // get parent pathname
  674. path = FN_RESOLVE(path,"child"); // get child pathname
  675.  
  676. ** FN_WHAT() **
  677.  
  678. STR name = FN_WHAT(STR pathname);
  679.  
  680. The FN_WHAT() function returns just the filename portion of a full pathname.
  681.  
  682. Examples:
  683. file = FN_WHAT("Q240:Desktop Folder:My File");
  684. PRINT(file);        // prints "My File"
  685.  
  686. ** FN_WHERE() **
  687.  
  688. STR path = FN_WHERE(STR pathname);
  689.  
  690. The FN_WHERE() function returns just the path portion of a full pathname. The filename is removed from the pathname. Note that the path portion of the pathname must be valid in order for this function to work.
  691.  
  692. Examples:
  693. path = FN_WHERE("Q240:Desktop Folder:My File");
  694. PRINT(path);        // prints "Q240:Desktop Folder:"
  695.  
  696. ** FN_PACK() **
  697.  
  698. STR packed = FN_PACK(STR fullname);
  699.  
  700. The FN_PACK() function takes a full pathname/filename and returned it in a special "packed" format. In packed format, the total length will never exceed 48 characters, regardless of the pathname. The packed pathname/filename can be converted back to normal form with the FN_UNPK() function.
  701.  
  702. Examples:
  703. pack = FN_PACK("Q240:Desktop Folder:Stuff:My File");
  704.  
  705. ** FN_UNPK() **
  706.  
  707. STR fullname = FN_UNPK(STR packname);
  708. The FN_UNPK() function takes a packed pathname/filename and converts it back to unpacked form. In unpacked form, the total length is limited only by the number of folders involved in the path.
  709.  
  710. Examples:
  711. pack = FN_PACK("Q240:Desktop Folder:Stuff:My File");
  712.  
  713. ** FN_SCAN() **
  714.  
  715. STR batch = FN_SCAN(STR path, STR creator, STR types, STR match);
  716.  
  717. The FN_SCAN() function returns the names of files present in a particular folder. You can restrict the scan by creator and one or more filetypes and/or by filenames. Set the creator and/or types and/or match to null to avoid restricting the scan. If the filename match string is used, it must be a complete match using * as a wildcard character (case does not matter). The resulting list is returned as a string in array-string format (same as FN_BATCH).
  718.  
  719. Examples:
  720. batch = FN_SCAN("Q240:Stuff:","PTM1","");
  721. IF (batch == "") { RETURN }
  722. list = FN_SCAN("Q240:Stuff:","","","User *");
  723.  
  724. ** FN_OPEN() **
  725.  
  726. STR file = FN_OPEN(INT index, STR button, STR filetypes);
  727.  
  728. The FN_OPEN() function lets a user choose a file using the standard file selector. The pathname index determine the default folder to start the file selector at (see Pathname Indexes at the start of this section). Button is the name of the button displayed in the file selector. Filetypes is a string containing one or more filetypes which should be displayed (filetypes not listed are not displayed by the file selector window). Use a filetype of "????" to list all files.
  729.  
  730. Examples:
  731. file = FN_OPEN(0,"Open","TEXTMACR");
  732. IF (file == "") { RETURN }
  733.  
  734. ** FN_SAVE() **
  735.  
  736. STR file = FN_SAVE(INT index, STR prompt, STR defname);
  737.  
  738. The FN_SAVE() function displays a standard file save dialog and allows the user to enter a new filename. The pathname index determines the default folder to start the file selector at (see Pathname Indexes at the start of this section). Prompt is the text displayed as a prompt above the filename input field. Defname is the default filename initially displayed in the filename input field.
  739.  
  740. Examples:
  741. file = FN_SAVE(1,"Save File As","Untitled");
  742. IF (file == "") { RETURN }
  743. F_CREATE(file);
  744.  
  745. ** FN_PATH() **
  746.  
  747. STR path = FN_PATH(INT index, STR button);
  748.  
  749. The FN_PATH() function displays a standard file folder selection dialog. The pathname index determines the default folder to start the file selector at (see Pathname Indexes at the start of this section). Button is the name of the button displayed in the file selector. 
  750.  
  751. Example:
  752. path = FN_PATH(4,"Select");
  753. IF (path != "") { SET_PATH(4,path) }
  754.  
  755. ** FN_BATCH() **
  756.  
  757. STR batch = FN_BATCH(INT index, STR button);
  758.  
  759. The FN_BATCH() function displays a batch file selection dialog (same as used in file transfer) and allows the user to select a list of files. The pathname index determines the default folder to start the file selector at (see Pathname Indexes at the start of this section). Button is the name of the button displayed in the batch file selector. The resulting batch is returned as a string-array of filenames. See the ARRAY_SIZE() and ARRAY_GET() functions for information on extracting the individual filenames from the array.
  760.  
  761. Examples:
  762. batch = FN_BATCH(3,"Done");
  763. IF (batch == "") { RETURN }
  764. fnum = 1;
  765. fmax = ARRAY_SIZE(batch,1);
  766. WHILE (fnum <= fmax) {
  767.   PRINT(FN_UNPK(ARRAY_GET(batch,fnum)),"^m");
  768.   fnum = fnum + 1;
  769. }
  770.  
  771. ** FN_GETPATH() **
  772.  
  773. INT pathname = FN_GETPATH(INT index);
  774.  
  775. The FN_GETPATH() function returns the current pathname for a particular pathname index. See Pathname Indexes at the start of this section for more information.
  776.  
  777. Examples:
  778. PRINT(FN_GETPATH(1));
  779.  
  780. ** FN_SETPATH() **
  781.  
  782. FN_SETPATH(INT index, STR pathname);
  783.  
  784. The FN_SETPATH() function sets the current pathname for a particular pathname index. See Pathname Indexes at the start of this section for more information.
  785.  
  786. Examples:
  787. FN_SETPATH(1, メHD80:ProTERM:モ);
  788. FN_SETPATH(1, FN_GETPATH(5));
  789.  
  790. ** FN_GETSPR() **
  791.  
  792. INT spring = FN_GETSPR(INT index);
  793. The FN_GETSPR() function returns the メspringbackモ setting of a particular pathname index. See Pathname Indexes at the start of this section for more information.
  794.  
  795. Examples:
  796. PRINT(FN_GETSPR(1));
  797.  
  798. ** FN_SETSPR() **
  799.  
  800. FN_SETSPR(INT index, INT spring);
  801. The FN_SETSPR() function sets the メspringbackモ option of the particular pathname index. See Pathname Indexes at the start of this section for more information.
  802.  
  803. Examples:
  804. FN_SETSPR(1, #true);
  805. FN_SETSPR(2, #false);
  806.  
  807. ** F_EXISTS() **
  808.  
  809. STR type = F_EXISTS(STR filename);
  810.  
  811. The F_EXISTS() function returns a string which indicates the file type of the file (if it exists) or null (if it does not). If the file is actually a folder, then it returns the string "fldr".
  812.  
  813. Examples:
  814. IF (F_EXISTS("q240:stuff:test file") != "") { PRINT(メfile existsモ) }
  815.  
  816. ** F_CREATE() **
  817.  
  818. INT error = F_CREATE(STR filename);
  819.  
  820. The F_CREATE() function creates a new file of the given name (data fork only). The file creator is the same as the application and the file type is TEXT. To change the creator or type, use the F_GETINFO() and F_SETINFO() functions (see below). This function returns zero for no-error, negative for error.
  821.  
  822. Examples:
  823. F_CREATE("q240:stuff:test file");
  824.  
  825. ** F_FOLDER() **
  826.  
  827. INT error = F_FOLDER(STR foldername);
  828.  
  829. THE F_FOLDER() function creates a new empty folder of the given name. This function returns zero for no-error, negative for error.
  830.  
  831. Examples:
  832. F_FOLDER("Q240:New Folder");
  833.  
  834. ** F_DELETE() **
  835.  
  836. INT error = F_DELETE(STR filename);
  837.  
  838. The F_DELETE() function deletes the named file or folder. The return value is zero for no-error, negative for error.
  839.  
  840. Examples:
  841. F_DELETE("q240:stuff:test file");
  842.  
  843. ** F_RENAME() **
  844.  
  845. INT error = F_RENAME(STR old_name, STR new_name);
  846.  
  847. The F_RENAME() function renames a file from old_name to new_name.. The new_name must be a simple filename, or a pathname in the same folder. The F_RENAME() function will not move files. The return value is zero for no-error, negative for error.
  848.  
  849. Examples:
  850. F_RENAME("q240:stuff:test file","untested file");
  851.  
  852. ** F_GETINFO() **
  853.  
  854. INT info = F_GETINFO(STR filename);
  855.  
  856. The F_GETINFO() function returns information about a file in a special "packed" string format. The return value is a 50 byte packed string of information, or the null string if there is an error. The data within the string has the following meaning:
  857.  
  858.     Offset    Meaning                Access
  859.     ------    -------                ------
  860.       00      Access                NUM_BYTE(STR_MID(info,0))
  861.       01      unused                n/a
  862.     02..05    Type                STR_MID(info,2,4)
  863.     06..09    Creator                STR_MID(info,6,4)
  864.     10..11    Finder Flags            NUM_WORD(STR_MID(info,10))
  865.     12..23    unused                n/a
  866.     24..27    Logical Data Size        NUM_LONG(STR_MID(info,24))
  867.     28..31    Physical Data Size        NUM_LONG(STR_MID(info,28)
  868.     32..33    unused                n/a
  869.     34..37    Logical Resource Size        NUM_LONG(STR_MID(info,34))
  870.     38..41    Physical Resource Size        NUM_LONG(STR_MID(info,38))
  871.     42..45    Creation Date/Time        NUM_LONG(STR_MID(info,42))
  872.     46..49    Modification Date/Time        NUM_LONG(STR_MID(info,46))
  873.  
  874. Examples:
  875. info = F_GETINFO("q240:stuff:test file");
  876. PRINTF("Type = %s^n",STR_MID(info,2,4));
  877.  
  878. ** F_SETINFO() **
  879.  
  880. INT error = F_SETINFO(STR filename, STR info);
  881.  
  882. The F_SETINFO() function sets information about a file. The information is passed in a special "packed" string format which corresponds to that returned by the F_GETINFO() function (see above). The return value is zero for no-error, negative for an error.
  883.  
  884. Examples:
  885. info = F_GETINFO("q240:stuff:test file");
  886. info = STR_LEFT(info,2)+"TEXT"+STR_MID(info,6);
  887. F_SETINFO("q240:stuff:test file",info);
  888.  
  889. ** F_OPEN() **
  890.  
  891. INT file_ref = F_OPEN(STR filename, STR access);
  892.  
  893. The F_OPEN() function opens an existing file for later input/output via the input/output (see the next section). The access string is equal to "RO", "RW" or "SH" for read-only, read write or shared file access. The return value is a positive "reference number" if the open succeeds, or a negative error code.
  894.  
  895. Examples:
  896. INT fd = F_OPEN("q240:stuff:test file");
  897.  
  898. ** F_CLOSE() **
  899.  
  900. INT error = F_CLOSE(INT file_ref);
  901.  
  902. The F_CLOSE() function closes an open file given its reference number. The return value is zero for no-error, negative for error.
  903.  
  904. Examples:
  905. F_CLOSE(fd);
  906.  
  907. □*** Input/Output Functions ***
  908.  
  909. The input/output functions are used to transfer data from one device to another. A メdeviceモ is a generic reference to a programming object such as a files, window, or session. Since devices are a rather abstract concept, something concrete is needed to represent them in programs. All of the I/O routine make use of メreference numbersモ (abbreviated refnums) to indicate the device being used. There are functions which return refnums for use with files, windows and sessions. See the functions F_OPEN(), F_CLOSE(), WIN_FIND(), SES_GET() for more information on getting refnums to devices.
  910.  
  911. ** IO_PRINTF() **
  912.  
  913. INT error = IO_PRINTF(INT refnum, STR format, [VAR arg1] [ ... ])
  914.  
  915. The IO_PRINTF() function creates a formatted text string and outputs it to the refnum device. The control string is used as a template for the final formatted text. In addition to normal text, the control string can contain special メformatting codesモ which are replaced in the final text by additional arguments formatted according to the code. See the STR_FORMAT() function for syntax of the control string.
  916.  
  917. Examples:
  918. err = IO_PRINT(fd,メ%d^mモ,x);
  919.  
  920. ** IO_SCANF() **
  921.  
  922. INT items = IO_SCANF(INT refnum, STR format, [VAR arg1] [ ... ]);
  923.  
  924. The IO_SCANF() function parses data from a device, assigning it to variables according to a format string. This function operates similar to the C scanf function, except it includes some additional control over what defines a string (i.e., it can be more than just a white-space terminated sequence of characters). The return value indicates the number of variables assigned by the function. The syntax of the format string is identical to that used by STR_PARSE().
  925.  
  926. Examples:
  927. IO_SCANF(fd,"%s^m",text);
  928.  
  929. ** IO_READ() **
  930.  
  931. STR data = IO_READ(INT refnum, INT length);
  932.  
  933. The IO_READ() function returns a string of 'length' bytes read from the device. The refnum could be a file_ref from a F_OPEN() function, or a reference to some other device* (such as a window). A null string is returned for any kind of error.
  934.  
  935. Examples:
  936. text = IO_READ(fd,32);
  937.  
  938. ** IO_WRITE() **
  939.  
  940. INT count = IO_WRITE(INT refnum, INT length, STR data);
  941.  
  942. The IO_WRITE() function writes a string of 'length' bytes to a device. If'length' is smaller than the size of string, only 'length' characters are written. Otherwise, if 'length' is larger than the size of the string, the write is "padded" with null characters until 'length' bytes are written. By passing an empty string, you can quickly write a sequence of nulls to a device. The return value is the number of bytes actually written.
  943.  
  944. Examples:
  945. IO_WRITE(#OutChan,50,"Hello World");
  946.  
  947. ** IO_COPY() **
  948.  
  949. INT length = IO_COPY(INT inp_ref, INT out_ref, INT limit | STR term_chars );
  950.  
  951. The IO_COPY() function copyies data from one device to another. The amount of data copied is determined by the thind argument. If this argument is a number, it represents the number of bytes to copy. If this argument is a  string, it represents a list of "terminator characters" which mark the end of the copy. The null-string copies the entire contents of the input device to the output device.
  952.  
  953. Examples:
  954. fd = F_OPEN("q240:desktop folder:test file","RO");
  955. IO_COPY(fd,#OutChan,"");
  956. F_CLOSE(fd);
  957.  
  958. ** IO_GETLEN() **
  959.  
  960. INT size = IO_GETLEN(INT refnum);
  961.  
  962. The IO_GETLEN() function returns the length of a device. The refnum can be a file_ref from F_OPEN(), a win_ref from WIN_FIND(), or a reference to some other device (such as a session). The result is the length of the device or -1 if the length is unavailable.
  963.  
  964. Examples:
  965. size = IO_GETLEN(fd);
  966.  
  967. ** IO_SETLEN() **
  968.  
  969. INT error = IO_SETLEN(INT refnum, INT length);
  970.  
  971. The IO_SETLEN() function sets the length of a device. The refnum can be a file_ref from a F_OPEN() function, or a reference to some other device (such as a window). The return value is zero for no-error, negative for error.
  972.  
  973. Examples:
  974. IO_SETLEN(fd,size);
  975.  
  976. ** IO_GETPOS() **
  977.  
  978. INT position = IO_GETPOS(INT refnum);
  979.  
  980. The IO_GETPOS() function returns the read/write position of a device. The refnum can be a file_ref from a F_OPEN() function, or a reference to some other device (such as a window). The result is the read/write position of the device or -1 if the position is unavailable.
  981.  
  982. Examples:
  983. pos = IO_GETPOS(fd);
  984.  
  985. ** IO_SETPOS() **
  986.  
  987. INT error = IO_SETPOS(INT refnum, INT position);
  988.  
  989. The IO_SETPOS() function sets the read/write position of a device. The refnum can be a file_ref from a F_OPEN() function, or a reference to some other device (such as a window). The return value is zero for no-error, negative for error.
  990.  
  991. Examples:
  992. IO_SETPOS(fd,pos)
  993.  
  994. ** IO_GETSEL() **
  995.  
  996. INT position = IO_GETSEL(INT refnum);
  997.  
  998. The IO_GETSEL() function returns the メanchorモ position of a device. The refnum can be a win_ref from WIN_ACTIVE() (files do not support anchor points). The result is the anchor position of the device or -1 if the anchor position is unavailable.
  999.  
  1000. Examples:
  1001. pos = IO_GETSEL(fd);
  1002.  
  1003. ** IO_SETSEL() **
  1004.  
  1005. INT error = IO_SETSEL(INT refnum, INT position);
  1006.  
  1007. The IO_SETSEL() function sets the メanchorモ position of a device. The refnum can be a win_ref from WIN_ACTIVE() (files do not support anchor points). The return value is zero for no-error, negative for error. Setting the anchor position to point different from the read/write position usually has the effect of creating a selection, though the exact result differs from device to device.
  1008.  
  1009. Examples:
  1010. IO_SETSEL(fd,pos)
  1011.  
  1012. ** IO_INPCHAN() **
  1013.  
  1014. IO_INPCHAN(INT alias, INT refnum);
  1015.  
  1016. The IO_INPCHAN() function allows remapping of input half of a device alias. All subsequent input from the alias will get its input from refnum instead.
  1017.  
  1018. Examples:
  1019. IO_INPCHAN(#stdin,refnum);
  1020.  
  1021. ** IO_OUTCHAN() **
  1022.  
  1023. IO_OUTCHAN(INT alias, INT refnum);
  1024.  
  1025. The IO_OUTCHAN() function allows remapping of output half of a device alias. All subsequent output to the alias will be sent to refnum instead.
  1026.  
  1027. Examples:
  1028. IO_OUTCHAN(#stdin,refnum);
  1029.  
  1030. □*** Miscellaneous Functions ***
  1031.  
  1032. The following functions do not fit into any particular category or description.
  1033.  
  1034. ** PRINT() **
  1035.  
  1036. PRINT(EXPR data, [ ... ]);
  1037.  
  1038. The PRINT() function displays the value of each argument in the Macro Output window. There can be one or more arguments and each can be either an integer or a string.
  1039.  
  1040. Examples:
  1041. PRINT(メhello worldモ);    // display メhello worldモ
  1042. PRINT(27);        // display 27
  1043. PRINT(TICKS(),メ^mモ);    // displays tick count plus return
  1044. PRINT(1,メ2モ,3,メ^mモ);    // display メ123モ plus return
  1045.  
  1046. ** PRINTF() **
  1047.  
  1048. PRINTF(STR control, [EXPR arg1] [ ... ]);
  1049.  
  1050. The PRINTF() function creates a formatted text string and displays it in the Macro Output window. The control string is used as a template for the final formatted text. In addition to normal text, the control string can contain special メformatting codesモ which are replaced in the final text by additional arguments formatted according to the code. See the STR_FORMAT() function for syntax of the control string.
  1051.  
  1052. Examples:
  1053. PRINTF(メtime: %D %T^mモ, 0,0);        // display current date & time
  1054. PRINTF(メ%s %s ^mモ, メhelloモ, メworldモ);    // display メhello worldモ
  1055. PRINTF(メ%d%% doneモ, x);            // display a percent value
  1056.  
  1057. ** TIME() **
  1058.  
  1059. INT time = TIME(INT where);
  1060.  
  1061. The TIME() function returns the current time in elapsed seconds from January 1, 1904. The where argument indicates if the time should be returned in local (where = 0) or GMT (where = 1). By recording the value of TIME() and then subtracting it from a later value, you can determine elapsed time.
  1062.  
  1063. Examples:
  1064. start = TIME();        // record the start time
  1065. ...do something...    // perform some computations
  1066. et = TIME()-start;    // compute elapsed time
  1067. PRINT(et);        // display elapsed seconds
  1068.  
  1069. ** TICK() **
  1070.  
  1071. INT tick = TICK();
  1072.  
  1073. The TICK() function returns the elapsed メticksモ since the computer was last restarted. A tick occurs every 1/60 of a second. By recording the value of TICK() and then subtracting it from a later value, you can determine elapsed ticks.
  1074.  
  1075. Examples:
  1076. start = TICK();        // record the start tick
  1077. ...do something...    // perform some computations
  1078. et = TICK()-start;    // compute elapsed ticks
  1079. PRINTF(メ%Eモ,et);    // display elapsed seconds (ticks/60)
  1080.  
  1081. ** ARGV() **
  1082.  
  1083. INT value = ARGV(INT index);
  1084.  
  1085. The ARGV() function returns a function argument by its index number. Each argument passed to a function is numbered starting at one and can be retrieved with the ARGV() function. Arguments beyond those specified in the function declaration can only be accessed with the ARGV() function.
  1086.  
  1087. Examples:
  1088. PRINT(ARGV(1));        // print the first function argument
  1089. PRINT(ARGV(2));        // print the second function argument
  1090.  
  1091. ** ARGC() **
  1092.  
  1093. INT count = ARGC();
  1094.  
  1095. The ARGC() function returns a count of the arguments passed to the current function. The ARGC() function is used to create functions that can accept a variable number of arguments. If no arguments were passed to the current function, ARGC() returns a count of 0.
  1096.  
  1097. Example:
  1098. FUNC print2()            // declare function without args
  1099. {                // start of func compound expr
  1100.  INT i = 0;            // start argument index at 0
  1101.  WHILE ((i=i+1) <= ARGC()) {    // while index < total arguments, loop
  1102.   PRINT(ARGV(i);        // display the argument
  1103.  }
  1104.  RETURN;            // return from function (void)
  1105. }                // end of func compound expr
  1106.  
  1107. ** ERROR(STR error_message); **
  1108.  
  1109. The ERROR() function causes a macro error and displays the error_message argument as the error cause. This function is useful in writing library routines which will be called by other macros. It provides a clean way to terminate a macro and provide an explanation to the user.
  1110.  
  1111. Examples:
  1112. ERROR("Out of Range");
  1113.  
  1114. ** GESTALT() **
  1115.  
  1116. STR result = GESTALT(descriptor);
  1117.  
  1118. The GESTALT() function returns attributes of the environment in which the macro is executing. The descriptor (listed below) is the name of the attribute which should be returned. If the descriptor is invalid, GESTALT() returns a null string. The GESTALT() function can be used to see if the particular version of the software is in use or return information about the computer hardware.
  1119.  
  1120. The following descriptors are supported:
  1121.  
  1122.     appl    Returns the name of the application (ProTERM).
  1123.     vers    Returns the ProTERM version name.
  1124.     name    Returns the name of the registered user.
  1125.     org    Returns the organization of the registered user.
  1126.     serial    Returns the software serial number.
  1127.     mac    Returns the model name of the Macintosh hardware.
  1128.     cpu    Returns the cpu/fpu being used.
  1129.     ram    Returns the physical memory in the computer.
  1130.     rom    Returns the size of the ROM in the computer.
  1131.     update    Returns the installed update file version (4-digit string)
  1132.  
  1133. NOTE: You can actually add your own GESTALT() values by declaring a shared string variable of the desired name. If you create your own macro library, you can use GESTALT() to メadvertiseモ when it is available and what version is being used.
  1134.  
  1135. NOTE: Experts-- GESTALT() can also be used to query the system software about attributes of the current software/hardware. To call the toolbox _GESTALT function, use the form: INT value = GESTALT(NUM_LONG("selector")); where 'selector' is the 4 byte _GESTALT selector.
  1136.  
  1137. Examples:
  1138. PR(GESTALT(name));            // send user name to the service
  1139. PRINT(GESTALT(mac));            // display Mac hardware model
  1140. sysv = GESTALT(NUM_LONG("sysv"));    // get system software version
  1141.  
  1142. ** EXTERN() **
  1143.  
  1144. INT result = EXTERN(STR macro_file, EXPR expression);
  1145.  
  1146. The EXTERN() function evaluates an expression within the context of a different macro file. All function references in expression are executed from macro_file instead of from the current program. The result returned by EXTERN() is the result of the expression. If macro_file is null, then the expression is evaluated from the disk-based copy of the current macro program (not the copy already in memory).
  1147.  
  1148. Examples:
  1149. EXTERN(メlibraryモ,main());    // exec a different macro file
  1150. x = EXTERN(メlibモ, sum(1, 2));    // exec the function メsumモ in the file メlibモ
  1151.  
  1152. ** RESIDENT() **
  1153.  
  1154. RESIDENT(STR macro_file, INT owner, INT access);
  1155.  
  1156. The RESIDENT() function is used to make a macro_file resident. If the macro_file is null, then the RESIDENT() function affects the current macro program. The owner is a number between 0 and 32,000 that identifies the macro_file and controls how the macro_file can be accessed. The owner should always be set to 0. The access argument indicates how functions in the macro_file can be executed (keyboard, event, library). An access of -1 means that macro_file should no longer be kept resident.
  1157.  
  1158. The values for the access argument are all predefined constants. Each constant allows a certain type of access to the macro file. All of the desired access types should be added together as the access expression.
  1159.  
  1160. #KeyAccess
  1161.         The macro file is scanned for KEY_0000(), KTR_0000() and KED_0000() functions that correspond to otherwise unused keypresses.
  1162.  
  1163. #EventAccess
  1164.         The macro file is scanned for EV_xxxx() functions that correspond to ProTERM events.
  1165.  
  1166. #LibAccess
  1167.         The macro file is scanned when a function reference in a different macro file cannot locate a matching function declaration.
  1168.  
  1169. #DefnAccess
  1170.         The macro file is scanned for KDF_0000() functions that correspond to every keypress. This kind of access allows any possible keypress to activate a macro (even keys that should be performing some other function). Use of this access type is not recommended.
  1171.  
  1172. Examples:
  1173. RESIDENT(メモ, 0, #KeyAccess+#EventAccess);
  1174.             // make resident and allow keyboard/event access
  1175. RESIDENT(メモ, 0, -1);    // remove resident status
  1176.  
  1177. ** TIME_OF() **
  1178.  
  1179. INT time = TIME_OF(INT year, INT month, INT day, INT hour, INT min, INT sec);
  1180.  
  1181. The TIME_OF() function converts a given year, month, day, hour, minute and second into a single time value which represents the number of elapsed seconds from January 1, 1904. This is the same time format used by all the other macro time routines.
  1182.  
  1183. Examples:
  1184. tm = TIME_OF(1995,3,22,18,56,17);    // return value for 3/22/95 6:56:17 pm
  1185.  
  1186. ** TIME_TO() **
  1187.  
  1188. INT value = TIME_TO(INT time, INT select);
  1189.  
  1190. The TIME_TO() function returns either the year, month, day, hour, minute, second or day-of-week component from a time value. The select values are 0=year, 1=month, 2=day, 3=hour, 4=minute, 5=second, 6=day-of-week. A time value of 0 is equivilent to the "current time".
  1191.  
  1192. Examples:
  1193. month = TIME_TO(0,1);    // extract current month
  1194. year = TIME_TO(0,0);    // extract current year
  1195. day = TIME_TO(0,2);    // extract current day
  1196. PRINTF("%02d/%02d/%02d",month,year,day);
  1197.  
  1198. □*** User Interface Functions ***
  1199.  
  1200. User Interface Functions
  1201. The following group of functions allow control over the user interface. These functions allow a macro program to perform operations such as choosing a command from a menu, clicking a button in a window or entering text. For other functions which can control the user interface, see Dialog Interface Functions below.
  1202.  
  1203. ** UI_NEW() **
  1204.  
  1205. UI_NEW(STR file_name);
  1206.  
  1207. The UI_NEW() function creates a new editor document with the specified name. It is functually equivilent to choosing the New command followed by the Save command and entering a filename. To create the file in a particular folder, the file name should include the folder path specification.
  1208.  
  1209. Examples:
  1210. UI_NEW(メTest Fileモ);        // create editor doc メTest Fileモ
  1211. UI_NEW(メHD80:ProTERM:New Fileモ);
  1212.  
  1213. ** UI_OPEN() **
  1214.  
  1215. UI_OPEN(STR file_name);
  1216.  
  1217. The UI_OPEN() function opens an existing file. The type of the file determines how it is opened (as an editor, connect or terminal window document). The file name should include the folder path specification for the file.
  1218.  
  1219. Examples:
  1220. UI_OPEN(メExisting Fileモ);    // open a document called test file
  1221. UI_OPEN(メHD80:ProTERM:Existing Fileモ);
  1222.  
  1223. ** UI_CLOSE() **
  1224.  
  1225. UI_CLOSE(STR file_name);
  1226.  
  1227. The UI_CLOSE() function closes an open document of the corresponding name. All open documents are scanned until one with a matching name is located. Note that the UI_CLOSE() function does not prompt you to save changes to the document even if it has been changed. If you want to save changes to the document, use the UI_SAVE() function prior to the UI_CLOSE() function.
  1228.  
  1229. Examples:
  1230. UI_CLOSE(メTest Fileモ);        // close a document called test file
  1231. UI_CLOSE(メHD80:ProTERM:Test Fileモ);
  1232.  
  1233. ** UI_SAVE() **
  1234.  
  1235. UI_SAVE(STR file_name);
  1236.  
  1237. The UI_SAVE() function saves the changes to an open document of the corresponding name. All open documents are scanned until one with a matching name is located.
  1238.  
  1239. Examples:
  1240. UI_SAVE(メTest Fileモ);        // save a document called test file
  1241. UI_SAVE(メHD80:ProTERM:Test Fileモ);
  1242.  
  1243. ** UI_CLICK() **
  1244.  
  1245. UI_CLICK(STR button_name);
  1246.  
  1247. The UI_CLICK() function clicks a button in the active window. The button_name must be completely spelled out, but uppercase and lowercase do not matter.
  1248.  
  1249. Examples:
  1250. UI_CLICK(メOKモ);        // click the OK button
  1251. UI_CLICK(メmacrosモ);    // click Macros radio button
  1252.  
  1253. ** UI_SET() **
  1254.  
  1255. UI_SET(STR item_name, STR value);
  1256.  
  1257. The UI_SET() function sets the value of an item in the active window. The item_name must be completely spelled out, but uppercase/lowercase and any trailing colon do not matter. The new value of the item must correspond to a valid choice for that item (i.e., if item_name is a pop-up`, then value must be one of the choices in the pop-up menu).
  1258.  
  1259. Examples:
  1260. UI_SET(メspeedモ, メ9600 BPSモ);    // set the speed option to 9600 bps
  1261. UI_SET(メSpeedモ, メ2400 BPSモ);    // set the speed option to 2400 bps
  1262. UI_SET(メSPEED:モ, メ300 BPSモ);    // set the speed option to 300 bps
  1263.  
  1264. ** UI_GET() **
  1265.  
  1266. STR value = UI_GET(STR item_name);
  1267.  
  1268. The UI_GET() function returns the current value of an item in the active window. The item_name must be completely spelled out, but uppercase and lowercase, and any trailing colons do not matter.
  1269.  
  1270. Examples:
  1271. speed = UI_GET(メspeedモ);    // get the speed option
  1272. phone = UI_GET(メDuplex:モ);    // get the duplex option
  1273.  
  1274. ** UI_MENU() **
  1275.  
  1276. UI_MENU(STR command_name);
  1277.  
  1278. The UI_MENU() function chooses a command_name from one of the pull-down menus. The command_name must be expressed as メmenu:commandモ, or if located in a submenu, メmenu:submenu:commandモ. The names of the menus and commands must be completely spelled out, but uppercase and lowercase does not matter.
  1279.  
  1280. Examples:
  1281. UI_MENU(メEdit:Convert:Lower Caseモ);    // choose lowercase from convert menu
  1282. UI_MENU(メfile:openモ);            // choose file from the open menu
  1283.  
  1284. ** UI_EQUIV() **
  1285.  
  1286. UI_EQUIV(STR command_name, STR key_equiv);
  1287.  
  1288. The UI_EQUIV() function sets the keyboard equivalent (shortcut) for a menu command. The command_name must be expressed as メmenu:commandモ, or if located in a submenu, メmenu:submenu:commandモ. The names of the menus and commands must be completely spelled out, but uppercase/lowercase does not matter. The key_equiv should be a single character. Once a keyboard equivalent is set, it remains in effect until ProTERM quits or the shortcut is changed with another UI_EQUIV() function. To remove the keyboard equivalent from command_name, pass the empty string (メモ).
  1289.  
  1290. Examples:
  1291. UI_EQUIV(メEdit:Convert:Lowercaseモ,メLモ);    // make COMMAND+L into shortcut
  1292. UI_EQUIV(メFile:Printモ, メモ);        // remove shortcut from print
  1293.  
  1294. ** UI_TYPE() **
  1295.  
  1296. UI_TYPE(STR text);
  1297.  
  1298. The UI_TYPE() function makes it appear that text is being typed at the keyboard. Text is processed by the active window. The UI_TYPE() function is normally used to insert text into an editor window. Text is always inserted at the insertion point.
  1299.  
  1300. Examples:
  1301. UI_TYPE(メhello worldモ);        // enter the text メhello worldモ
  1302. UI_TYPE(ヤThis is a メQuoteモ Testユ);
  1303.  
  1304. ** UI_CLIP() **
  1305.  
  1306. STR from_clip = UI_CLIP(STR to_clip);
  1307. INT value = UI_CLIP(INT flag);
  1308.  
  1309. The UI_CLIP() function allows text to be copied to the clipboard or the current clipboard contents to be read. To read the clipboard, pass the null string as the function argument. The clipboard contents are returned as a single string. To copy text to the clipboard, pass the text to the UI_CLIP function. That text replaces the previous contents of the clipboard. By passing a value of zero to UI_CLIP(), you can determine the size of the data in the clipboard.
  1310.  
  1311. Examples:
  1312. clip = UI_CLIP("");    // get current clipboard contents
  1313. UI_CLIP("hello");    // put "hello" on the clipboard
  1314. x = UI_CLIP(0);        // assign x the size of clipboard contents
  1315.  
  1316. ** UI_SOUND() **
  1317.  
  1318. UI_SOUND(STR sound);
  1319.  
  1320. The UI_SOUND() function allows a macro to play a sound resource. The sound must be an available sound resource. The easiest way to determine a list of available sounds is to look at one of the sound pop-up menus in the Sounds page of the Preferences.
  1321.  
  1322. After the UI_SOUND function starts playing a sound, it resumes macro execution immediately BEFORE the sound has finished playing. To wait for completion of the current sound, pass the null string as the sound_name.
  1323.  
  1324. Examples:
  1325. UI_SOUND("Simple Beep");    // play the standard beep
  1326.  
  1327. ** UI_SPEAK() **
  1328.  
  1329. UI_SPEAK(STR speak_text);
  1330.  
  1331. The UI_SPEAK() function allows a macro to use the Speech Manager (if installed) to speak. After the UI_SPEAK() function starts speaking, it resumes macro execution BEFORE the speech has finished. To wait for completion of the speech, pass the null string as the speak_text.
  1332.  
  1333. To determine if the Speech Manager is installed (and whether UI_SPEAK can be used), use the GESTALT() function with the SPEECH descriptor. If the result is anything but メNo", you can assume speech is present.
  1334.  
  1335. Examples:
  1336. IF (GESTALT(SPEECH) != "No") { UI_SPEAK("Hello World"); }
  1337. UI_SPEAK("");        // wait for current speech to complete
  1338.  
  1339. ** UI_CMD **
  1340.  
  1341. STR result = UI_CMD(STR cdl);
  1342.  
  1343. The UI_CMD() function is not intended for use by the average user. It is an interface to a special internal command language used by the application to control its actions. Certain complex functions use UI_CMD() in order to interface more directly with internal routines.
  1344.  
  1345. ** UI_NUM **
  1346.  
  1347. INT value = UI_NUM(STR parm INT index, STR cdl_result);
  1348.  
  1349. The UI_NUM() function is used to extract a numeric result value generated by the UI_CMD() function. It is not intended for use by the average user and is included only for completeness.
  1350.  
  1351. ** UI_STR **
  1352.  
  1353. STR value = UI_STR(STR parm INT index, STR cdl_result);
  1354.  
  1355. The UI_STR() function is used to extract a string result value generated by the UI_CMD() function. It is not intended for use by the average user and is included only for completeness.
  1356.  
  1357. □*** Window Functions ***
  1358.  
  1359. The following group of functions control the manipulation of windows. The WIN_OPEN(), WIN_MACRO(), WIN_BUTTON(), WIN_ICON() and WIN_PICT() allow special windows to be created that execute macros in response to clicking in the window.
  1360.  
  1361. ** WIN_OPEN() **
  1362.  
  1363. INT window_id = WIN_OPEN(STR title, INT type, INT width, INT length);
  1364.  
  1365. The WIN_OPEN() function creates a special kind of メmacro windowモ to which you can add buttons, icons and pictures. You can then add specific macros which are executed in response to clicking in the window with the mouse. The window type is 0 for a standard window (like an editor window) and 1 for a floating window (like the keypad window). The width and length specify the initial size of the window in pixels. The window_id returned by this function must be saved in a variable for use with the WIN_MACRO(), WIN_BUTTON(), WIN_ICON() and WIN_PICT() functions.
  1366.  
  1367. The resulting window has メspacesモ reserved to display items. Each space is numbered from 1 to 20 and can be assigned a unique button, icon or picture to identify it. Each space can also be assigned a macro to execute when the corresponding button, icon or picture is clicked with the mouse. Whenever the window is displayed, the items are displayed left to right, top to bottom starting with item 1. Whenever the window is resized, the items are redisplayed in a メbest fitモ format.
  1368.  
  1369. NOTE: If the length value is negative, this acts as a flag to tell DIRC to maintain the size and position of the window between uses. Whenever the user changes the size of the window, DIRC will remember it for next time.
  1370.  
  1371. Examples:
  1372. win = WIN_OPEN(メTestモ,0,200,200);    // open a normal window called メtestモ
  1373. win = WIN_OPEN(メモ,1,200,300);        // open an untitled floating window
  1374.  
  1375. ** WIN_BUTTON() **
  1376.  
  1377. WIN_BUTTON(INT window_id, INT item_num, STR button_name);
  1378.  
  1379. The WIN_BUTTON() function adds a button to a macro window. The window_id must be from a prior WIN_OPEN() function. The item_num should be in the range 1 to 20 and correspond to the desired メitem spaceモ (where 1 is at the upper-left corner and 20 is towards the lower-right). The button_name should be limited to no more than 15 characters total.
  1380.  
  1381. The text for button names should always be left-justified. In order to pad the width of a button (add more space between the button name and the frame), add trailing spaces to the button text. To make multiple buttons have the same width, make sure they all have the same number of characters in the button text (including trailing spaces).
  1382.  
  1383. Examples:
  1384. WIN_BUTTON(win,1,メbtnモ);    // add button called メbtnモ
  1385. WIN_BUTTON(win, 1, "Ymodem       ");
  1386. WIN_BUTTON(win, 2, "Ymodem-4K    ");
  1387. WIN_BUTTON(win, 3, "Ymodem-G     ");
  1388.  
  1389. ** WIN_ICON() **
  1390.  
  1391. WIN_ICON(INT window_id, INT item_space, STR icon_name);
  1392.  
  1393. The WIN_ICON() function adds an icon to a macro window. The window_id must be a result from a prior WIN_OPEN() function. The item_num should be in the range 1 to 20 and correspond to the desired メitem spaceモ (where 1 is at the upper-left corner and 20 is towards the lower-right). The icon_name is the name of an icon resource. Valid icon_names can be determined by choosing Macro Icon Info from the Tools: Additions submenu.
  1394.  
  1395. Examples:
  1396. WIN_ICON(win,1,メstopモ);        // add メstopモ icon to win
  1397.  
  1398. ** WIN_PICT() **
  1399.  
  1400. WIN_PICT(INT window_id, INT item_num, STR pict_name);
  1401.  
  1402. The WIN_PICT() function adds a picture to a macro window. The window_id must be from a prior WIN_OPEN() function. The item_num should be in the range 1 to 20 and correspond to the desired メitem spaceモ (where 1 is at the upper-left corner and 20 is towards the lower-right). The pict_name is the name of a picture resource. Valid pict_names can be determined by choosing Macro Icon Info from the Tools: Additions submenu.
  1403.  
  1404. Examples:
  1405. WIN_PICT(win, 1, メintrecモ);    // add intrec pict to win
  1406.  
  1407. ** WIN_CLICK() **
  1408.  
  1409. INT item_space = WIN_CLICK(INT window_id);
  1410.  
  1411. The WIN_CLICK() function waits for a click on an item (button, icon or picture) in a macro window. The window_id must be from a prior WIN_OPEN() function. The item_space value represents the corresponding number of the item. An item_space value of -1 means that the macro window was closed.
  1412.  
  1413. Examples:
  1414. item = WIN_CLICK(WIN_FIND(メMacro Windowモ));
  1415.  
  1416. ** WIN_MACRO() **
  1417.  
  1418. WIN_MACRO(INT window_id, INT item_space, STR macro_text);
  1419.  
  1420. The WIN_MACRO() function associates a macro with an item (button, icon or picture) in a macro window. The item_space is a number between 1 and 20 that corresponds to the button, icon or picture that should be associated with the macro. The macro_text must be a complete stand-alone macro that could be executed as its own program. It must include all function and variable declarations required for it to execute.
  1421.  
  1422. When you click on the corresponding item, the macro_text is executed as a stand-alone macro independent of the macro program which referenced the WIN_MACRO function. If you want to メcommunicateモ between the two macros, you must use SESSION or SHARED variables. When the macro_text finishes executing, it does not return any kind of result to WIN_MACRO.
  1423.  
  1424. Examples:
  1425. win = WIN_OPEN(メTestモ,0,100,100);
  1426. WIN_MACRO(win,1,ヤprint(メhello worldモ);ユ);
  1427. WIN_BUTTON(win,1,メ#1モ);
  1428.  
  1429. ** WIN_FIND() **
  1430.  
  1431. INT window_id = WIN_FIND(STR title, [STR type]);
  1432.  
  1433. The WIN_FIND() function returns the window_id of an open window. The title must be exactly the same as the title of the window (both uppercase and lowercase count). If a type string is specified, it must correspond to the four-character type of the window. If the title is null, then any window matching the type field will be returned. If WIN_FIND() cannot locate the window, it returns a value of 0.
  1434.  
  1435. Examples:
  1436. win = WIN_FIND(メTest Windowモ);        // return window_id of メTest Windowモ
  1437. WIN_ACTIVE(WIN_FIND(メThe InTrec BBSモ));    // make メThe InTrec BBSモ window active
  1438.  
  1439. ** WIN_FILE() **
  1440.  
  1441. INT window_id = WIN_FILE(STR file);
  1442.  
  1443. The WIN_FILE() function returns the window_id of an open document window. The file must be exactly the same as the name of the file that corresponds to the window. If WIN_FILE() cannot locate the window, it returns a value of 0.
  1444.  
  1445. Examples:
  1446. win = WIN_FIND(メHD80:PT:Editor Docモ);    // return id of メEditor Docモ window
  1447. WIN_ACTIVE(WIN_FIND(メHD80:PT:InTrecモ));    // make メInTrecモ window active
  1448.  
  1449. ** WIN_ACTIVE() **
  1450.  
  1451. INT window_id = WIN_ACTIVE(INT window_id);
  1452.  
  1453. The WIN_ACTIVE() function selects and/or returns the active window_id. If the window_id passed to WIN_ACTIVE() is valid, then that window is made active. The WIN_ACTIVE() function always returns the window_id of the active window or 0 if no window is open. To get the window_id of the active window without changing anything, pass a window_id of 0.
  1454.  
  1455. Examples:
  1456. win = WIN_ACTIVE(0);    // assign active window_id
  1457. WIN_ACTIVE(WIN_FIND(メModem Control Monitorモ));
  1458.             // make メmodem controlモ window active
  1459.  
  1460. ** WIN_MOVE() **
  1461.  
  1462. INT position = WIN_MOVE(INT window_id, INT horiz, INT vert);
  1463.  
  1464. The WIN_MOVE() function moves and/or returns the position of a window. The window to be moved is indicated by the window_id. The new horizontal and vertical position of the window is indicated in pixels (where 0,0 is the upper-left corner of the screen). To get the position of a window without changing it, pass vertical and horizontal both set to 0.
  1465.  
  1466. The position returned by the WIN_MOVE() function is in a special format. To convert the position into standard horizontal and vertical components, use the NUM_LO16() and NUM_HI16() functions. The horizontal position is equal to NUM_LO16(position) while the vertical position is equal to NUM_HI16(position).
  1467.  
  1468. Examples:
  1469. pos = WIN_MOVE(win,0,0);    // get position of window
  1470. horiz = NUM_LO16(pos);        // extract horizontal position
  1471. vert = NUM_HI16(pos);        // extract vertical position
  1472. WIN_MOVE(WIN_ACTIVE(0),50,50);
  1473.  
  1474. ** WIN_SIZE() **
  1475.  
  1476. INT size = WIN_SIZE(INT window_id, INT horiz, INT vertical);
  1477.  
  1478. The WIN_SIZE() function resizes and/or returns the size of a window. The window to be resized is indicated by the window_id. The new horizontal and vertical size of the window is indicated in pixels. To return the size of a window without changing it, pass vertical and horizontal both set to 0. You can only resize a window that can normally be resized with the mouse (a window with a grow box).
  1479.  
  1480. The size returned by the WIN_SIZE() function is in a special format. To convert the size into standard horizontal and vertical components, use the NUM_LO16() and NUM_HI16() functions. The horizontal size is equal to NUM_LO16(size) while the vertical size is equal to NUM_HI16(size).
  1481.  
  1482. Examples:
  1483. size = WIN_SIZE(win,0,0);        / get the size of the window
  1484. horiz = NUM_LO16(size);            // extract horizontal size
  1485. vert = NUM_HI16(size);            // extract vertical size
  1486. WIN_SIZE(WIN_ACTIVE(0),100,200);    // set size of the active window
  1487.  
  1488. ** WIN_ZOOM() **
  1489.  
  1490. STR state = WIN_ZOOM(INT window_id, STR zoom);
  1491.  
  1492. The WIN_ZOOM() function zooms and/or returns the zoom state of a window. The window to zoom is indicated by the window_id. The zoom string is a single character that indicates the new zoom state. The following states are supported:
  1493.  
  1494.     ~    Toggles between normal and zoom
  1495.     <    Zoom to minimum size
  1496.     >    Zoom to maximum size
  1497.     {    Zoom to maximum vertical size
  1498.     }    Zoom to maximum horizontal size
  1499.     -    Change to normal state
  1500.     +    Change to zoom state
  1501.  
  1502. The state returned by WIN_ZOOM() indicates the zoom state of the window (and corresponds to the table above). To get the zoom state of the window without changing it, pass an empty zoom string.
  1503.  
  1504. Examples:
  1505. WIN_ZOOM(WIN_ACTIVE(0)),メ~モ);
  1506. zoom = WIN_ZOOM(win, メモ);
  1507.  
  1508. ** WIN_NAME() **
  1509.  
  1510. STR name = WIN_NAME(INT window_id);
  1511.  
  1512. The WIN_NAME() function returns the name of an open window. The name corresponds to the name displayed in the title bar of the window.
  1513.  
  1514. Examples:
  1515. PRINTF(メWindow name = %s^mモ, WIN_NAME(WIN_ACTIVE(0)));
  1516.  
  1517. ** WIN_TYPE() **
  1518.  
  1519. STR type = WIN_TYPE(INT window_id);
  1520.  
  1521. The WIN_TYPE() function returns a special four character type string for the window. The type string can be used to identify one kind of window from another. For example, an editor window returns a different type than a terminal window.
  1522.  
  1523. Examples:
  1524. PRINTF(メWindow type = %s^mモ, WIN_TYPE(WIN_ACTIVE(0)));
  1525. IF (WIN_TYPE(win) == メEDITモ) BREAK;
  1526.  
  1527. ** WIN_CLOSE() **
  1528.  
  1529. WIN_CLOSE(INT window_id);
  1530.  
  1531. The WIN_CLOSE() function closes an open window. The window_id must be a valid value returned by the WIN_OPEN(), WIN_FIND() or WIN_ACTIVE() functions.
  1532.  
  1533. Examples:
  1534. WIN_CLOSE(win);            // close window in メwinモ
  1535. WIN_CLOSE(WIN_ACTIVE(0));    // close the active window
  1536.  
  1537. ** WIN_NOTE() **
  1538.  
  1539. INT button = WIN_NOTE(INT type, STR text);
  1540.  
  1541. The WIN_NOTE() function displays some kind of メnoteモ in a window. The type determines which type of icon should be displayed (alert, note, warning) and what button choices are available (OK, Cancel, Yes, No or a combination). The following types are supported:
  1542.  
  1543.     1    Icon = Stop; Button = OK (default).
  1544.     2    Icon = Note; Buttons = Cancel, OK (default).
  1545.     3    Icon = Alert; Buttons = OK, Cancel (default).
  1546.     4    Icon = Note; Button = OK (default)
  1547.     5    Icon = Alert; Buttons = Yes (default), No, Cancel.
  1548.  
  1549. The result returned by WIN_NOTE() is a number that corresponds to the button that was pressed. The buttons return the following values: OK=1, Cancel=-1, Yes=1, No=0.
  1550.  
  1551. Examples:
  1552. WIN_NOTE(1, メMacro Failedモ);
  1553. WIN_NOTE(5, メContinue with macro?モ);
  1554.  
  1555. ** WIN_WAIT(INT window_id); **
  1556.  
  1557. The WIN_WAIT() function waits for a window to close. The WIN_WAIT() function is useful for synchronizing the activity of a macro to user interaction within a window.
  1558.  
  1559. Examples:
  1560. WIN_WAIT(WIN_FIND(メTestモ));    // wait for window called メtestモ to close
  1561. WIN_WAIT(WIN_ACTIVE(0));    // wait for the active window to close
  1562.  
  1563. □*** Dialog Functions ***
  1564.  
  1565. The dialog functions allow DIRC to create a complete dialog windows and interact with the user in the same mannor as the application. From the perspective of the user, there is no way to tell the difference between a dialog created by the メapplicationモ and by a メmacroモ. 
  1566.  
  1567. Creating dialog windows takes some effort, but can be done without too much difficulty. There are basically four steps involved: First, use the dialog functions to build a dialog template string. The string is a specia "description" of the dialog which DIRC creates the actual dialog from. Second, use the D_OPEN() function to open the dialog. Third, use D_EVENT() to monitor the dialog (i.e., check for button clicks). Fourth, close the window after the you are finished using it (usually after the user presses a button or clicks the close box).
  1568.  
  1569. A dialog description is long string which is created by concatenating together dialog element functions (buttons, input fields, static text, dividers, etc) to a window frame (returned by the D_NEW() function). Many of the dialog element functions use a "where" argument which is a string that describes where that particular element should be positioned within the window. Generally, it is useful to position dialog elements relative to prior elements (with the first element in the upper-left corner). DIRC includes simple, but powerful way of expressing the location of each element in text form. The following code sample shows an example dialog description:
  1570.  
  1571.  STR intro = D_NEW(0,0,240,350,0,"AutoTime Setup")+
  1572.   D_FORM("WT+0 WL+0",40,20,"Current Timezone:")+
  1573.   D_DIVIDER("PB+5 WL-50",1,500,0)+
  1574.   D_TEXT("PB+5 WL+0","Select Time Server")+
  1575.   D_RADIO("PB+0 WL+0",1,rad303)+
  1576.   D_RADIO("PB+0 WL+0",1,rad202)+
  1577.   D_DIVIDER("PB+5 WL-50",1,500,0)+
  1578.   D_TOGGLE("PB+5 WL+0",togdst)+
  1579.   D_DIVIDER("PB+7 WL-50",1,500,0)+
  1580.   D_TEXT("PB+5 WL+0",
  1581.    "WARNING: This macro makes a long-distance^m"+
  1582.    "phone call in order to get the correct time^m"+
  1583.    "and reset your Macintosh system clock."
  1584.   )+
  1585.   D_DIVIDER("PB+10 WL-50",1,500,0)+
  1586.   D_DEFAULT("WB-0 WL+0","Start")+
  1587.   D_BUTTON("PY+0 PR+15","Cancel");
  1588.  
  1589. The D_NEW() function defines the window frame and style while the other functions (such as D_FORM, D_DIVIDER, D_TEXT, D_RADIO, D_TOGGLE, D_DEFAULT and D_BUTTON) each create individual dialog elements within the window. The first argument to each of these functions is a string which determines where to place the element. The string takes the form of "vert_base+offset horiz_base+offset". The codes ("PB", "WT", "PY", etc.) give the basis from which the new position should be measured. The offset (+0, +5, +10, -0, etc.) give the exact position relative to the base position. The valid positioning codes are:
  1590.  
  1591.  WT - Align top of item relative to top of window.
  1592.  WB - Align bottom of item relative to bottom of window.
  1593.  WL - Align left of item relative to left of window.
  1594.  WR - Align right of item relative to right of window.
  1595.  
  1596.  PT - Align top of item relative to bottom of previous item.
  1597.  PB - Align bottom of item relative to top of previous item.
  1598.  PY - Align baseline of item relative to baseline of previous item.
  1599.  PL - Align left of item relative to right of previous item.
  1600.  PR - Align right of item relative to left of previous item.
  1601.  PX - Align basepoint of item relative to basepoint of previous item.
  1602.  
  1603.  AT - Align top of item relative to absolute top of window
  1604.  AB - Align bottom of item relative to absolute top of window.
  1605.  AY - Align baseline of item relative to absolute top of window.
  1606.  AL - Align left of item relative to absolute left of window.
  1607.  AR - Align right of item relative to absolute left of window.
  1608.  AX - Align basepoint of item relative to absolute left of window.
  1609.  
  1610. Example:
  1611.  
  1612. INT win,prog;
  1613. STR tmpl,event;
  1614.  
  1615. tmpl = D_NEW(0,0,60,300,2+4+256,"Processing")+
  1616.  D_FORM("WT+0 WL+0",100,-1,"Status:")+
  1617.  D_PROG("WB-3 WL+0",13,200,"~prog")+
  1618.  D_BUTTON("WB+0 WR+0","Stop");
  1619.  
  1620. win = D_OPEN(tmpl);
  1621. prog = 0;
  1622. WHILE (prog <= 100) {
  1623.  event = D_EVENT(win,1,"B");
  1624.  D_SET(win,"~prog",STR_NUM(prog));
  1625.  IF (event != "") { BREAK }
  1626.  prog = prog + 1;
  1627.  DELAY(5); // do work here
  1628. }
  1629. D_CLOSE(win);
  1630. END;
  1631.  
  1632. ---
  1633.  
  1634. There is one little "gotcha" about this macro. It is important to do the
  1635. D_SET() right after the D_EVENT(). This is because doing a D_SET() has the side
  1636. effect of signaling a change in the dialog. If you do a D_SET() following by a
  1637. D_EVENT(win,1,""), you will get back "~prog" indicating the progress indicator
  1638. has changed. In fact, it has. You just changed it with D_SET(). This kind of
  1639. feedback may seem strange, but it is necessary since there is no way for the
  1640. dialog to actually know who changed what or why. The "event" queue for a dialog
  1641. is only 1 item deep so the most recent item remains.
  1642.  
  1643. ** D_NEW() **
  1644.  
  1645. STR tmpl = D_NEW (INT top, INT left, INT len, INT wid, INT type, STR title);
  1646.  
  1647. The D_NEW() function returns a description of a dialog window for use with the
  1648. D_OPEN() function. Use this function at the start of a dialog template description to specify the location, size, type and title of a window. The window type is determines by adding together special values. The following values are available:
  1649.  
  1650. * Window Type Values *
  1651.  
  1652.        1 = Unused
  1653.        2 = Allow resizing (no grow box displayed)
  1654.        4 = Display zoom box
  1655.        8 = Draw window with drop-shadow
  1656.       16 = Display title bar (set automatically if title is not null)
  1657.       32 = Modal dialog window
  1658.       64 = Rounded corners on window
  1659.      128 = Display as floating window
  1660.      256 = Display close box
  1661.      512 = Allow color (set automatically for non-white background)
  1662.     1024 = Open as bottom window (instead of as top)
  1663.  
  1664. Examples:
  1665. tmpl = D_NEW(0, 0, 100, 300, 16+256, "Test Window");
  1666.  
  1667. ** D_FONT() **
  1668.  
  1669. STR tmpl = D_FONT(STR fontname, INT fontsize, INT kind);
  1670.  
  1671. The D_FONT() function sets the desired font for all items which follow it in a dialog template. The font for "prompts" and "input" can be set separately. This means that an input field can use a different font for the prompt and input. The two "kind" values are 1=prompt, 2=input. 
  1672.  
  1673. Examples:
  1674. tmpl = tmpl + D_FONT("monaco",9,2);    // use monaco-9 for next input field
  1675.  
  1676. ** D_BUTTON() **
  1677.  
  1678. STR tmpl = D_BUTTON(STR where, STR title);
  1679.  
  1680. The D_BUTTON() function adds a button to a dialog template. The 'where' argument specifies where the button should be displayed. The 'title' is the name of the button.
  1681.  
  1682. Examples:
  1683. tmpl = tmpl + D_BUTTON("WB-0 WL+0","OK"); // add OK button to lower-left
  1684.  
  1685. ** D_DEFAULT() **
  1686.  
  1687. STR tmpl = D_DEFAULT(STR where, STR title);
  1688.  
  1689. The D_DEFAULT() function adds a "default button" to a dialog template. The default button has a highlight drawn around it. When return is pressed, it is the same as clicking the default button. A dialog may contain only a single default button. See D_BUTTON() for more information.
  1690.  
  1691. Examples:
  1692. tmpl = tmpl + D_DEFAULT("WB-0 WL+0","OK"); // add default OK button to LL
  1693.  
  1694. ** D_TOGGLE() **
  1695.  
  1696. STR tmpl = D_TOGGLE(STR where, STR name);
  1697.  
  1698. The D_TOGGLE() function adds a checkbox to a dialog template. The checkbox is initially off unless preceded by a D_PRESET() function. 
  1699.  
  1700. Examples:
  1701. tmpl = tmpl + D_TOGGLE("PB+0 WL+0","Checkbox Test");    // add checkbox
  1702.  
  1703. ** D_RADIO() **
  1704.  
  1705. STR tmpl = D_RADIO(STR where, INT group, STR name);
  1706.  
  1707. The D_RADIO() function adds a radio button to a dialog template. The 'group' specifies which radio buttons are associated with each other. When you click on a radio button, all other radio buttons in that same group are turned off.
  1708.  
  1709. Examples:
  1710. tmpl = tmpl + D_RADIO("PB+0 WL+0",1,"My Radio Button");    // add radio button
  1711.  
  1712. ** D_INPUT() **
  1713.  
  1714. STR tmpl = D_INPUT(STR where, INT maxlen, INT width, INT length, STR prompt);
  1715.  
  1716. The D_INPUT() function adds an input field to a dialog template. The 'maxlen' limits the length of the input which can be entered in the field. The 'width' and 'length' control the size of the input rectangle. You can use -1 for either 'length' or 'width' to use an internally calculated default value. The 'prompt' is the text which appears to the left of the input. A 'prompt' which starts with the tilda (~) character is not displayed (but can still be used to reference the field).
  1717.  
  1718. Examples:
  1719. tmpl = tmpl + D_INPUT("PB+0 WL+0",50,100,16,"Your Name:");
  1720.  
  1721. ** D_IMAGE() **
  1722.  
  1723. STR tmpl = D_IMAGE(STR where, INT type, STR resname);
  1724.  
  1725. The D_IMAGE() function is used to display an image in a dialog (either an icon or picture). The 'type' indicates what kind of image should be displayed. It can be 'PICT', 'ICON', 'cicn', 'icn8', 'icn4' or 'icn#'. The 'resname' corresponds to a resource usually located in the PT Images file.
  1726.  
  1727. Examples:
  1728. tmpl = tmpl + D_IMAGE("PB+0 WL+0",$"PICT","Logo");
  1729.  
  1730. ** D_DIVIDER() **
  1731.  
  1732. STR tmpl = D_DIVIDER(STR where, INT length, INT width, INT pattern);
  1733.  
  1734. The D_DIVIDER() function displays a divider line within a dialog (horizontal, vertical or rectangular). A horizontal or vertical line is created by using a 'length' or 'width' of 1. The 'pattern' indicates whether a dashed or solid divider is drawn (0=dashed, 1=solid).
  1735.  
  1736. Examples:
  1737. tmpl = tmpl + D_DIVIDER("PB+0 WL+0",300,1,0);
  1738.  
  1739. ** D_TEXT() **
  1740.  
  1741. STR tmpl = D_TEXT(STR where, STR text);
  1742.  
  1743. The D_TEXT() function displays static text within a dialog. The text cannot be changed within the dialog. The text can include RETURN characters if the text uses more than a single line.
  1744.  
  1745. Examples:
  1746. tmpl = tmpl + D_TEXT(STR where, STR text);
  1747.  
  1748. ** D_FORM() **
  1749.  
  1750. STR tmpl = D_FORM(STR where, INT width, INT length, STR prompt);
  1751.  
  1752. The D_FORM() function is used to create a dynamic text area which you can change after a dialog is displayed. If the 'prompt' starts with the tilda (~) character, then it is not displayed (but is still used to reference the item). A form is very much like an input item except the user cannot change it and it has no border.
  1753.  
  1754. Examples:
  1755. tmpl = tmpl + D_FORM("PB+0 WL+0", 100, 16, "~player");
  1756.  
  1757. ** D_PROG() **
  1758.  
  1759. STR tmpl = D_PROG(STR where, INT height, INT width, STR title);
  1760.  
  1761. The D_PROG() function is used to add a progress indicator to a dialog template.
  1762. Once the indicator is added, use D_SET() to change its value. The 'title' string is required in order to be able to identify the item for D_SET(). If you don't want a title of the item, prefix the title with a tilde (such as ~prog). This gives the item a title you can use with D_SET() without displaying it.
  1763.  
  1764. ** D_POPUP() **
  1765.  
  1766. STR tmpl = D_POPUP(STR where, INT resid, STR prompt);
  1767.  
  1768. The D_POPUP() function is used to add a popup menu to a dialog template. The popup menu must already exist (either through the use of a utility such as ResEdit or via the D_MENU() function).
  1769.  
  1770. Examples:
  1771. tmpl = tmpl + D_POPUP("WT+0 WL+0",768,"Speed:");
  1772.  
  1773. ** D_MENU() **
  1774.  
  1775. INT resid = D_MENU(INT resid, STR desc);
  1776.  
  1777. The D_MENU() function allows a popup menu to be created for use with the D_POPUP() function. If the 'resid' argument is zero, then D_MENU() returns a recently unused resid number (this allows dynamic popup menus to be created). The format of the menu itself is the same as used by the Macintosh Toolbox _AddMenuDesc trap;
  1778.  
  1779. Examples:
  1780. resid = D_MENU(0,"Hello;-;World");
  1781.  
  1782. ** D_LIST() **
  1783.  
  1784. STR tmpl = D_LIST(STR where, INT width, INT length, STR title);
  1785.  
  1786. The D_LIST() function allows a list item to be added to a dialog. After the list item is added, the list contents must be set after the dialog is displayed using the D_CONTENT() function.
  1787.  
  1788. Examples:
  1789. STR tmpl = D_LIST("WT-10 WL-10",100,200,"~list");
  1790.  
  1791. ** D_GROW() **
  1792.  
  1793. The D_GROW() function is used to add a grow box to a dialog. Though some window types may show the grow box even without D_GROW() as part of the dialog description, D_GROW() should be included when a grow box is required.
  1794.  
  1795. Examples:
  1796. STR tmpl = D_GROW();
  1797.  
  1798. ** D_PRESET() **
  1799.  
  1800. STR tmpl = D_PRESET(VAR value);
  1801.  
  1802. The D_PRESET() function is used to assign initial values to dialog items. When a dialog is first created, the items within the dialog usually have "empty" values (input fields are blank, checkboxes are unchecked, etc.) The D_PRESET() function allows initial item values to be specified within the template. A D_PRESET() must be used immediately prior to the item which contains the data to be preset.
  1803.  
  1804. NOTE: Not every dialog element type accepts the D_PRESET() function (D_FORM() and D_LIST() do not). As an alternative to D_PRESET(), you can use D_SET() after a dialog is created to set the value of a particular item.
  1805.  
  1806. Examples:
  1807. tmpl = tmpl + D_PRESET("Test") + D_INPUT("PB+0 WL+0",50,100,16,"Your Name:");
  1808. tmpl = tmpl + D_PRESET(1) + D_TOGGLE("PB+0 WL+0","Checkbox Test");
  1809.  
  1810. ** D_GET() **
  1811.  
  1812. STR value = D_GET(INT win, STR what);
  1813.  
  1814. The D_GET() function is used to return the value of a dialog item. The 'win' must be a valid open dialog window. The 'what' is the name of the individual item. D_GET() is used to extract user input from a dialog.
  1815.  
  1816. Examples:
  1817. PRINTF("%s^m",D_GET(win,"My Name:"));
  1818.  
  1819. ** D_SET() **
  1820.  
  1821. D_SET(INT win, STR what, STR value);
  1822.  
  1823. The D_SET() function is used to set the value of a dialog item. The 'win' must be a valid open dialog window. The 'what' is the name of the individual item. The 'value' is the new value for the item. D_SET() is used to set values for items which are not set with D_PRESET().
  1824.  
  1825. ** D_CONTENT() **
  1826.  
  1827. D_CONTENT(INT win, STR item, STR data);
  1828.  
  1829. The D_CONTENT() function is used to set the contents a dialog item. This is different from the value of a dialog item. The idea of contents applies to certain types of dialog items such as popup menu and list boxes. Within these items, the contents represents the list of possible choices while the value represents the current choice. At present, D_CONTENT() can only be used with list boxes.
  1830.  
  1831. The format of D_CONTENT() data for a list box is an array created using the ARRAY_xxx() functions. The array should be created to the proper length in advance with the proper number of entries (extra entries will display as blank lines).
  1832.  
  1833. Examples:
  1834. D_CONTENT(win,"~list",index());
  1835.  
  1836. ** D_MOVE() **
  1837.  
  1838. D_MOVE(INT win, INT top, INT btm, INT lft, INT rgt, INT new-top, INT new-lft);
  1839.  
  1840. The D_MOVE() function moves all the items within the rectangle defined by 'top', 'btm', 'lft', 'rgt' to a different rectangle starting at 'new-top', 'new-lft'. You can use D_MOVE() to create a multi-page dialog by moving groups of items off the visible dialog area to some "invisible" portion of the dialog (an area beyond the visible edge of the window) in response to the user changing some dialog item in the window.
  1841.  
  1842. Examples:
  1843. D_MOVE(0,0,100,200,0,400);    // move all in 0,0,100,200 rect to 0,400
  1844.  
  1845. ** D_SIZE() **
  1846.  
  1847. INT size = D_SIZE(INT win, STR what, INT width, INT length);
  1848.  
  1849. The D_SIZE() function changes the size of an item. The 'what' is the name of the individual item. After D_SIZE(), the dialog item will be redrawn to the new size. To "hide" an item, do not try and size it to 0,0. Instead, use D_MOVE() to move the item off the visible page.
  1850.  
  1851. Examples:
  1852.  
  1853. ** D_OPEN() **
  1854.  
  1855. win = D_OPEN(INT win, STR tmpl);
  1856.  
  1857. The D_OPEN function takes a dialog description and creates/opens the dialog window. It returns a window identifier for use with other window function. If the dialog cannot be created for some reason, D_OPEN() returns zero.
  1858.  
  1859. Examples:
  1860. D_OPEN();
  1861.  
  1862. ** D_EVENT() **
  1863.  
  1864. STR item = D_EVENT(INT win, INT timeout, STR filter);
  1865.  
  1866. The D_EVENT() function waits for activity within a dialog. The filter argument specifies what kind of events are returned (see the list below). The timeout argument specifies how long D_EVENT() should wait for an event (in 1/100th of a second). The timeout can be disabled by giving it a value of zero. D_EVENT() returns the title of the item causing the event, @GROW if the user resized the window, @CLOSE if the user closed the window, or null (empty string) for a timeout. The filter is a string of characters where each character represents a type of dialog item. The valid filter characters are:
  1867.  
  1868.  G = Grow box.
  1869.  B = Button.
  1870.  I = Input field.
  1871.  P = Popup menu.
  1872.  T = Toggle box.
  1873.  R = Radio button.
  1874.  L = List box.
  1875.  
  1876. Examples:
  1877. SWITCH(D_EVENT(win,50,"BGL")) { ... }
  1878.  
  1879. ** D_CLOSE() **
  1880.  
  1881. D_CLOSE(INT win);
  1882.  
  1883. The D_CLOSE() function will close an open dialog. This function should only be used to close dialog windows which were created by D_OPEN(). Using it to close dialog windows generated by the application can have unpredictable results.
  1884.  
  1885. Examples:
  1886. D_CLOSE(win);
  1887.  
  1888. □*** Menu Functions ***
  1889.  
  1890. The menu functions allow DIRC to create a new menu items and interact with the user in the same mannor as the application. From the perspective of the user, there is no way to tell the difference between a menu/menu-item created by the メapplicationモ and by a メmacroモ. 
  1891.  
  1892. ** MM_LOOKUP() **
  1893.  
  1894. STR item = MM_LOOKUP(STR where, INT index);
  1895.  
  1896. The MM_LOOKUP() function is used to determine what items are in a menu. The function requires a base menu reference (the 'where' argument) and an index into the menu (where 0 is the first item). If the index is out of range (beyond the end of the menu), null is returned.
  1897.  
  1898. Examples:
  1899. PRINT(MM_LOOKUP("File:",1));    // display "Open"
  1900.  
  1901. ** MM_KEY() **
  1902.  
  1903. STR key = MM_KEY(STR menu, STR key);
  1904.  
  1905. The MM_KEY() function will get/set the keyboard equivilent for a pulldown menu. This function performs the same operation as UI_EQUIV. In fact, UI_EQUIV() is a library function which calls MM_KEY() to do the work. To remove the keyboard equivilent for a menu item, set 'key' to space (" "). To get the current keyboard equivilent without changing it, set 'key' to null ("").
  1906.  
  1907. Examples:
  1908. MM_KEY("Edit:Make Index","-");
  1909.  
  1910. ** MM_MARK() **
  1911.  
  1912. STR mark = MM_MARK(STR menu, STR mark);
  1913.  
  1914. The MM_MARK() function will get/set the menu marker character for a pulldown menu. To remove an existing menu marker, set 'mark' to space (" "). To get the current marker, set 'mark' to null ("").
  1915.  
  1916. Examples:
  1917. MM_MARK("PTMM:Inbox",">");
  1918.  
  1919. ** MM_ICON() **
  1920.  
  1921. STR icon = MM_ICON(STR menu, STR icon);
  1922.  
  1923. The MM_ICON() function will get/set the menu icon for a pulldown menu. To remove an existing menu icon, set 'icon' to space (" "). To get the current menu icon, set 'icon' to null ("").
  1924.  
  1925. ** MM_STATE() **
  1926.  
  1927. STR state = MM_STATE(STR menu, STR state);
  1928.  
  1929. The MM_STATE() function determines how a pulldown menu item is enabled/disabled and made visible/invisible in response to the application state. This function operations by using a special "state code" to tell the menu system how to display menu according to the application state. Because of the complexity of the state code and the difficulty of use, this function should not be used. It is included only for completeness.
  1930.  
  1931. ** MM_CODE() **
  1932.  
  1933. STR code = MM_CODE(STR menu, STR code);
  1934.  
  1935. The MM_CODE() function determines the action that is performed by a pulldown menu. This function operates by assigning a CDL script to the menu item. CDL is a special internal command language which controls application operation. Because of the complexity of CDL and the difficulty of use, this function should not be used. It is included only for completeness.
  1936.  
  1937. ** MM_INSERT() **
  1938.  
  1939. STR menu = MM_INSERT(STR where, STR what, INT enable);
  1940.  
  1941. The MM_INSERT() function adds a new menu item to the pulldown menus. After the new item is added, it returns a special "menu identifier" string which can be used with other menu functions to get/set attributes of the menu. Since this function requires the use of MM_STATE() and MM_CODE() to be useful, and these functions are not intended for end-user use, this function is of little use for the average user.
  1942.  
  1943. ** MM_DELETE() **
  1944.  
  1945. INT error = MM_DELETE(STR menu);
  1946.  
  1947. The MM_DELETE() function will delete the named menu from the menubar. The menu specifier must be a full path including all submenus. A non-zero result indicates an error during the delete (menu not found).
  1948.  
  1949. Examples:
  1950. MM_DELETE("Connect:Rebuild Menu");
  1951.  
  1952. □*** Preference Functions ***
  1953.  
  1954. There are three functions which allow many preference values to be queried or set. The preferences control a variety of program options throughout the applications. Each individual preference is designated by a 4 character name which is passed to the function. The following preferences can be changed:
  1955.  
  1956. ** Preference Names **
  1957.  
  1958.   XSFG    (int) Foreground transfer complete sound (resource id)
  1959.   XSBG    (int) Background transfer complete sound (resource id)
  1960.   XC32    (int) Use CRC-32 (0 or 1)
  1961.   XFRC    (int) Force protocols according to menu (0 or 1)
  1962.   XTXT    (str) Default text file type (4 char string)
  1963.   XTXC    (str) Default text file creator (4 char string)
  1964.   XBIN    (str) Default binary file type (4 char string)
  1965.   XBIC    (str) Default binary file creator (4 char string)
  1966.   XSFN    (int) Force send-filename convert (1=Mac, 2=ProDOS, 3=UNIX, 4=MSDOS)
  1967.  
  1968.   KSOH    (str) Kermit start of packet character (numeric string)
  1969.   KEOL    (str) Kermit end of line character (numeric string)
  1970.   KMAX    (str) Kermit maximum packet length (numeric string)
  1971.   KTIM    (str) Kermit timeout (numeric string)
  1972.   KBIN    (int) Kermit transfer mode (0 or 1)
  1973.   KNPD    (str) Kermit padding character count (numeric string)
  1974.   KPAD    (str) Kermit padding character (numeric string)
  1975.  
  1976.   ZPAC    (int) Zmodem maximum send packet size
  1977.   ZWIN    (int) Zmodem send window size
  1978.   ZCTL    (int) Zmodem escape control-chars flag
  1979.   ZBUF    (int) Zmodem receive buffer size
  1980.  
  1981.   ESND    (int) Emulation bell sound (resource id)
  1982.   EREP    (int) Maximum bell repetition (1 to 100)
  1983.   ECOL    (int) Allow use of color by emulation (0 or 1)
  1984.   EHIL    (int) Highlight different sessions in term window (0 or 1)
  1985.  
  1986.   COFG    (int) Foreground connect sound (resource id)
  1987.   COBG    (int) Background connect sound (resource id)
  1988.   CQFG    (int) Foreground queued connect sound (resource id)
  1989.   CQBG    (int) Background queued connect sound (resource id)
  1990.  
  1991.   UFI1    (str) Uniform phone number, find #1
  1992.   URE1    (str) Uniform phone number, replace #1
  1993.   ...
  1994.   UFI6    (str) Uniform phone number, find #6
  1995.   URE6    (str) Uniform phone number, replace #6
  1996.  
  1997.   EDPA    (int) Show paragraphs in editor (0 or 1)
  1998.   EDSP    (int) Space white-space in editor (0 or 1)
  1999.   EDSM    (int) Enable smart-quotes in editor (0 or 1)
  2000.  
  2001. ** PREF_GET() **
  2002.  
  2003. VAR value = PREF_GET([INT scope,] STR pref);
  2004.  
  2005. The PREF_GET() function returns the current value of the specified preference. If the scope is omitted or zero, then the global preference value is returned. If scope corresponds to a session id, then the preference for that session is returned.
  2006.  
  2007. Examples:
  2008. x = PREF_GET(メEDSPモ);        // get value of editor space-show pref
  2009. y = PREF_GET(ses,メXSFNモ);    // get filename conversion pref
  2010.  
  2011. ** PREF_SET() **
  2012.  
  2013. PREF_SET([INT scope,] STR pref, VAR data);
  2014.  
  2015. The PREF_SET() function sets the value of the specified preference. If the scope is omitted or zero, then the global preference is set. If scope corresponds to a session id, then the preference is set for that session only.
  2016.  
  2017. Examples:
  2018. PREF_SET(メEDSPモ,1);        // enable editor space-show pref
  2019. PREF_SET(ses,メZCTLモ,1);        // make zmodem escape ctrl chars
  2020.  
  2021. ** PREF_DEL() **
  2022.  
  2023. PREF_DEL([INT scope,] STR pref, VAR data);
  2024.  
  2025. The PREF_DEL() function deletes the specified preference. Functions which would otherwise use that preference use a default value instead. If the scope is omitted or zero, then the global preference is deleted. If scope corresponds to a session id, then the preference is deleted for that session only.
  2026.  
  2027. Examples:
  2028. PREF_SET(メEDSPモ,1);        // enable editor space-show pref
  2029. PREF_SET(ses,メZCTLモ,1);        // make zmodem escape ctrl chars
  2030.  
  2031. □*** Macro Statement/Function Summary ***
  2032.  
  2033. BREAK;
  2034. CONTINUE;
  2035. DO { compound-expression }
  2036.     WHILE (boolean-expression);
  2037. END;
  2038. GOTO ident;
  2039. IF (boolean-expression) { compound-expression }
  2040. IF (boolean-expression) { compound-expression }
  2041.     ELSE { compound-expression }
  2042. RETURN(expression);
  2043. SWITCH (expression) {
  2044.  CASE expression: { compound-expression }
  2045.  CASE expression: { compound-expression }
  2046.  DEFAULT: { compound-expression }
  2047. }
  2048. WHILE (boolean-expression) { compound-expression }
  2049.  
  2050. ---
  2051.  
  2052. Last Updated: 07/31/96
  2053. (C)1996 InTrec Software, Inc.
  2054.